1
0
mirror of https://github.com/libp2p/go-libp2p-core.git synced 2025-03-31 13:30:06 +08:00

add SignedEnvelope type

This commit is contained in:
Yusef Napora 2019-11-06 12:24:34 -05:00
parent 52a4260be5
commit f4c9da5023
3 changed files with 526 additions and 67 deletions

79
crypto/envelope.go Normal file
View File

@ -0,0 +1,79 @@
package crypto
import (
"bytes"
"encoding/binary"
"errors"
"github.com/golang/protobuf/proto"
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
)
func MakeEnvelope(privateKey PrivKey, domain string, typeHint []byte, contents []byte) (*pb.SignedEnvelope, error) {
pubKey, err := PublicKeyToProto(privateKey.GetPublic())
if err != nil {
return nil, err
}
toSign := makeSigBuffer(domain, typeHint, contents)
sig, err := privateKey.Sign(toSign)
if err != nil {
return nil, err
}
return &pb.SignedEnvelope{
PublicKey: pubKey,
TypeHint: typeHint,
Contents: contents,
Signature: sig,
}, nil
}
func ValidateEnvelope(domain string, envelope *pb.SignedEnvelope) (bool, error) {
key, err := PublicKeyFromProto(envelope.PublicKey)
if err != nil {
return false, err
}
toVerify := makeSigBuffer(domain, envelope.TypeHint, envelope.Contents)
return key.Verify(toVerify, envelope.Signature)
}
func MarshalEnvelope(envelope *pb.SignedEnvelope) ([]byte, error) {
return proto.Marshal(envelope)
}
func UnmarshalEnvelope(serializedEnvelope []byte) (*pb.SignedEnvelope, error) {
e := pb.SignedEnvelope{}
if err := proto.Unmarshal(serializedEnvelope, &e); err != nil {
return nil, err
}
return &e, nil
}
func OpenEnvelope(domain string, envelope *pb.SignedEnvelope) ([]byte, error) {
valid, err := ValidateEnvelope(domain, envelope)
if err != nil {
return nil, err
}
if !valid {
return nil, errors.New("invalid signature")
}
return envelope.Contents, nil
}
func makeSigBuffer(domain string, typeHint []byte, content []byte) []byte {
b := bytes.Buffer{}
domainBytes := []byte(domain)
b.Write(encodedSize(domainBytes))
b.Write(domainBytes)
b.Write(encodedSize(typeHint))
b.Write(typeHint)
b.Write(encodedSize(content))
b.Write(content)
return b.Bytes()
}
func encodedSize(content []byte) []byte {
b := make([]byte, 8)
binary.BigEndian.PutUint64(b, uint64(len(content)))
return b
}

View File

@ -9,7 +9,6 @@ import (
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
@ -21,7 +20,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type KeyType int32
@ -88,7 +87,7 @@ func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PublicKey.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
@ -140,7 +139,7 @@ func (m *PrivateKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PrivateKey.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
@ -173,35 +172,109 @@ func (m *PrivateKey) GetData() []byte {
return nil
}
type SignedEnvelope struct {
PublicKey *PublicKey `protobuf:"bytes,1,req,name=PublicKey" json:"PublicKey,omitempty"`
TypeHint []byte `protobuf:"bytes,2,req,name=TypeHint" json:"TypeHint"`
Contents []byte `protobuf:"bytes,3,req,name=Contents" json:"Contents"`
Signature []byte `protobuf:"bytes,4,req,name=Signature" json:"Signature"`
}
func (m *SignedEnvelope) Reset() { *m = SignedEnvelope{} }
func (m *SignedEnvelope) String() string { return proto.CompactTextString(m) }
func (*SignedEnvelope) ProtoMessage() {}
func (*SignedEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_527278fb02d03321, []int{2}
}
func (m *SignedEnvelope) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SignedEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SignedEnvelope.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *SignedEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignedEnvelope.Merge(m, src)
}
func (m *SignedEnvelope) XXX_Size() int {
return m.Size()
}
func (m *SignedEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_SignedEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_SignedEnvelope proto.InternalMessageInfo
func (m *SignedEnvelope) GetPublicKey() *PublicKey {
if m != nil {
return m.PublicKey
}
return nil
}
func (m *SignedEnvelope) GetTypeHint() []byte {
if m != nil {
return m.TypeHint
}
return nil
}
func (m *SignedEnvelope) GetContents() []byte {
if m != nil {
return m.Contents
}
return nil
}
func (m *SignedEnvelope) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
func init() {
proto.RegisterEnum("crypto.pb.KeyType", KeyType_name, KeyType_value)
proto.RegisterType((*PublicKey)(nil), "crypto.pb.PublicKey")
proto.RegisterType((*PrivateKey)(nil), "crypto.pb.PrivateKey")
proto.RegisterType((*SignedEnvelope)(nil), "crypto.pb.SignedEnvelope")
}
func init() { proto.RegisterFile("crypto.proto", fileDescriptor_527278fb02d03321) }
var fileDescriptor_527278fb02d03321 = []byte{
// 203 bytes of a gzipped FileDescriptorProto
// 285 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0x2e, 0xaa, 0x2c,
0x28, 0xc9, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0xf1, 0x92, 0x94, 0x82, 0xb9,
0x38, 0x03, 0x4a, 0x93, 0x72, 0x32, 0x93, 0xbd, 0x53, 0x2b, 0x85, 0x74, 0xb8, 0x58, 0x42, 0x2a,
0x0b, 0x52, 0x25, 0x18, 0x15, 0x98, 0x34, 0xf8, 0x8c, 0x84, 0xf4, 0xe0, 0xca, 0xf4, 0xbc, 0x53,
0x2b, 0x41, 0x32, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x81, 0x55, 0x09, 0x49, 0x70, 0xb1,
0xb8, 0x24, 0x96, 0x24, 0x4a, 0x30, 0x29, 0x30, 0x69, 0xf0, 0xc0, 0x64, 0x40, 0x22, 0x4a, 0x21,
0x5c, 0x5c, 0x01, 0x45, 0x99, 0x65, 0x89, 0x25, 0xa9, 0x54, 0x34, 0x55, 0xcb, 0x92, 0x8b, 0x1d,
0xaa, 0x41, 0x88, 0x9d, 0x8b, 0x39, 0x28, 0xd8, 0x51, 0x80, 0x41, 0x88, 0x9b, 0x8b, 0xdd, 0x35,
0xc5, 0xc8, 0xd4, 0xd4, 0xd0, 0x52, 0x80, 0x51, 0x88, 0x97, 0x8b, 0x33, 0x38, 0x35, 0xb9, 0xc0,
0xc8, 0xd4, 0x2c, 0xdb, 0x50, 0x80, 0x49, 0x88, 0x93, 0x8b, 0xd5, 0xd5, 0xd9, 0x25, 0xd8, 0x51,
0x80, 0xd9, 0x49, 0xe2, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63,
0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0x00, 0x01, 0x00,
0x00, 0xff, 0xff, 0x13, 0xbe, 0xd4, 0xff, 0x19, 0x01, 0x00, 0x00,
0x5c, 0x5c, 0x01, 0x45, 0x99, 0x65, 0x89, 0x25, 0xa9, 0xd4, 0x34, 0x75, 0x0d, 0x23, 0x17, 0x5f,
0x70, 0x66, 0x7a, 0x5e, 0x6a, 0x8a, 0x6b, 0x5e, 0x59, 0x6a, 0x4e, 0x7e, 0x41, 0xaa, 0x90, 0x11,
0x92, 0xeb, 0xc1, 0xe6, 0x73, 0x1b, 0x89, 0x20, 0x99, 0x0f, 0x97, 0x0b, 0x42, 0xf2, 0xa4, 0x02,
0x17, 0x07, 0xc8, 0x22, 0x8f, 0xcc, 0xbc, 0x12, 0x14, 0x4b, 0xe0, 0xa2, 0x20, 0x15, 0xce, 0xf9,
0x79, 0x25, 0xa9, 0x79, 0x25, 0xc5, 0x12, 0xcc, 0xc8, 0x2a, 0x60, 0xa2, 0x42, 0x4a, 0x5c, 0x9c,
0x20, 0x97, 0x24, 0x96, 0x94, 0x16, 0xa5, 0x4a, 0xb0, 0x20, 0x29, 0x41, 0x08, 0x6b, 0x59, 0x72,
0xb1, 0x43, 0xfd, 0x27, 0xc4, 0xce, 0xc5, 0x1c, 0x14, 0xec, 0x28, 0xc0, 0x20, 0xc4, 0xcd, 0xc5,
0xee, 0x9a, 0x62, 0x64, 0x6a, 0x6a, 0x68, 0x29, 0xc0, 0x28, 0xc4, 0xcb, 0xc5, 0x19, 0x9c, 0x9a,
0x5c, 0x60, 0x64, 0x6a, 0x96, 0x6d, 0x28, 0xc0, 0x24, 0xc4, 0xc9, 0xc5, 0xea, 0xea, 0xec, 0x12,
0xec, 0x28, 0xc0, 0xec, 0x24, 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e,
0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x80,
0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xc0, 0x25, 0x32, 0xc8, 0x01, 0x00, 0x00,
}
func (m *PublicKey) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
@ -209,32 +282,26 @@ func (m *PublicKey) Marshal() (dAtA []byte, err error) {
}
func (m *PublicKey) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
var i int
_ = i
var l int
_ = l
if m.Data != nil {
i -= len(m.Data)
copy(dAtA[i:], m.Data)
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Data)))
i--
dAtA[i] = 0x12
}
i = encodeVarintCrypto(dAtA, i, uint64(m.Type))
i--
dAtA[i] = 0x8
return len(dAtA) - i, nil
i++
i = encodeVarintCrypto(dAtA, i, uint64(m.Type))
if m.Data != nil {
dAtA[i] = 0x12
i++
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Data)))
i += copy(dAtA[i:], m.Data)
}
return i, nil
}
func (m *PrivateKey) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
@ -242,38 +309,78 @@ func (m *PrivateKey) Marshal() (dAtA []byte, err error) {
}
func (m *PrivateKey) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PrivateKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
var i int
_ = i
var l int
_ = l
if m.Data != nil {
i -= len(m.Data)
copy(dAtA[i:], m.Data)
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Data)))
i--
dAtA[i] = 0x12
}
i = encodeVarintCrypto(dAtA, i, uint64(m.Type))
i--
dAtA[i] = 0x8
return len(dAtA) - i, nil
i++
i = encodeVarintCrypto(dAtA, i, uint64(m.Type))
if m.Data != nil {
dAtA[i] = 0x12
i++
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Data)))
i += copy(dAtA[i:], m.Data)
}
return i, nil
}
func (m *SignedEnvelope) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SignedEnvelope) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.PublicKey == nil {
return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("PublicKey")
} else {
dAtA[i] = 0xa
i++
i = encodeVarintCrypto(dAtA, i, uint64(m.PublicKey.Size()))
n1, err := m.PublicKey.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
if m.TypeHint != nil {
dAtA[i] = 0x12
i++
i = encodeVarintCrypto(dAtA, i, uint64(len(m.TypeHint)))
i += copy(dAtA[i:], m.TypeHint)
}
if m.Contents != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Contents)))
i += copy(dAtA[i:], m.Contents)
}
if m.Signature != nil {
dAtA[i] = 0x22
i++
i = encodeVarintCrypto(dAtA, i, uint64(len(m.Signature)))
i += copy(dAtA[i:], m.Signature)
}
return i, nil
}
func encodeVarintCrypto(dAtA []byte, offset int, v uint64) int {
offset -= sovCrypto(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
return offset + 1
}
func (m *PublicKey) Size() (n int) {
if m == nil {
@ -303,8 +410,40 @@ func (m *PrivateKey) Size() (n int) {
return n
}
func (m *SignedEnvelope) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.PublicKey != nil {
l = m.PublicKey.Size()
n += 1 + l + sovCrypto(uint64(l))
}
if m.TypeHint != nil {
l = len(m.TypeHint)
n += 1 + l + sovCrypto(uint64(l))
}
if m.Contents != nil {
l = len(m.Contents)
n += 1 + l + sovCrypto(uint64(l))
}
if m.Signature != nil {
l = len(m.Signature)
n += 1 + l + sovCrypto(uint64(l))
}
return n
}
func sovCrypto(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCrypto(x uint64) (n int) {
return sovCrypto(uint64((x << 1) ^ uint64((int64(x) >> 63))))
@ -539,10 +678,217 @@ func (m *PrivateKey) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *SignedEnvelope) Unmarshal(dAtA []byte) error {
var hasFields [1]uint64
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCrypto
}
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: SignedEnvelope: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SignedEnvelope: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCrypto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCrypto
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCrypto
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.PublicKey == nil {
m.PublicKey = &PublicKey{}
}
if err := m.PublicKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
hasFields[0] |= uint64(0x00000001)
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field TypeHint", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCrypto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthCrypto
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthCrypto
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.TypeHint = append(m.TypeHint[:0], dAtA[iNdEx:postIndex]...)
if m.TypeHint == nil {
m.TypeHint = []byte{}
}
iNdEx = postIndex
hasFields[0] |= uint64(0x00000002)
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Contents", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCrypto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthCrypto
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthCrypto
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Contents = append(m.Contents[:0], dAtA[iNdEx:postIndex]...)
if m.Contents == nil {
m.Contents = []byte{}
}
iNdEx = postIndex
hasFields[0] |= uint64(0x00000004)
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCrypto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthCrypto
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthCrypto
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...)
if m.Signature == nil {
m.Signature = []byte{}
}
iNdEx = postIndex
hasFields[0] |= uint64(0x00000008)
default:
iNdEx = preIndex
skippy, err := skipCrypto(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCrypto
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthCrypto
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if hasFields[0]&uint64(0x00000001) == 0 {
return github_com_gogo_protobuf_proto.NewRequiredNotSetError("PublicKey")
}
if hasFields[0]&uint64(0x00000002) == 0 {
return github_com_gogo_protobuf_proto.NewRequiredNotSetError("TypeHint")
}
if hasFields[0]&uint64(0x00000004) == 0 {
return github_com_gogo_protobuf_proto.NewRequiredNotSetError("Contents")
}
if hasFields[0]&uint64(0x00000008) == 0 {
return github_com_gogo_protobuf_proto.NewRequiredNotSetError("Signature")
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCrypto(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
@ -574,8 +920,10 @@ func skipCrypto(dAtA []byte) (n int, err error) {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
@ -596,30 +944,55 @@ func skipCrypto(dAtA []byte) (n int, err error) {
return 0, ErrInvalidLengthCrypto
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupCrypto
if iNdEx < 0 {
return 0, ErrInvalidLengthCrypto
}
depth--
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCrypto
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipCrypto(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthCrypto
}
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthCrypto
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
panic("unreachable")
}
var (
ErrInvalidLengthCrypto = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCrypto = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupCrypto = fmt.Errorf("proto: unexpected end of group")
ErrInvalidLengthCrypto = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCrypto = fmt.Errorf("proto: integer overflow")
)

View File

@ -18,3 +18,10 @@ message PrivateKey {
required KeyType Type = 1;
required bytes Data = 2;
}
message SignedEnvelope {
required PublicKey PublicKey = 1;
required bytes TypeHint = 2;
required bytes Contents = 3;
required bytes Signature = 4;
}