From 6e5dfcc1ba24ff5ecc4a4329a33f6d95a7906c3e Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Sun, 16 Jun 2024 21:34:45 +0900 Subject: [PATCH] upgrade lcp version Signed-off-by: Jun Kimura --- lcp | 2 +- light-clients/lcp/types/lcp.pb.go | 103 +++++++++++++++--------------- light-clients/lcp/types/update.go | 4 +- relay/lcp.go | 10 +-- sgx/ias/sgx.go | 8 +-- 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/lcp b/lcp index 2c441cc..96ca5ca 160000 --- a/lcp +++ b/lcp @@ -1 +1 @@ -Subproject commit 2c441cc4617a80809fff0b737cf3382a94069e9a +Subproject commit 96ca5ca949e93b7d824ac9ffede7c28ab2998f9d diff --git a/light-clients/lcp/types/lcp.pb.go b/light-clients/lcp/types/lcp.pb.go index db1c55d..a81cbbf 100644 --- a/light-clients/lcp/types/lcp.pb.go +++ b/light-clients/lcp/types/lcp.pb.go @@ -63,7 +63,7 @@ func (m *UpdateClientMessage) XXX_DiscardUnknown() { var xxx_messageInfo_UpdateClientMessage proto.InternalMessageInfo type RegisterEnclaveKeyMessage struct { - Report string `protobuf:"bytes,1,opt,name=report,proto3" json:"report,omitempty"` + Report []byte `protobuf:"bytes,1,opt,name=report,proto3" json:"report,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` SigningCert []byte `protobuf:"bytes,3,opt,name=signing_cert,json=signingCert,proto3" json:"signing_cert,omitempty"` OperatorSignature []byte `protobuf:"bytes,4,opt,name=operator_signature,json=operatorSignature,proto3" json:"operator_signature,omitempty"` @@ -241,50 +241,49 @@ func init() { func init() { proto.RegisterFile("ibc/lightclients/lcp/v1/lcp.proto", fileDescriptor_69f4c398e914fe8d) } var fileDescriptor_69f4c398e914fe8d = []byte{ - // 673 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcd, 0x52, 0x13, 0x4d, - 0x14, 0x4d, 0x20, 0xfc, 0xa4, 0x09, 0x7c, 0xf5, 0xb5, 0x14, 0x06, 0x94, 0x01, 0x42, 0x59, 0xb2, - 0x61, 0x22, 0x6a, 0xb9, 0x17, 0xc4, 0x32, 0x65, 0x81, 0xe5, 0x80, 0x1b, 0x36, 0x53, 0x9d, 0x99, - 0xeb, 0xa4, 0x8b, 0x99, 0xee, 0xb1, 0xbb, 0x13, 0x88, 0xef, 0x60, 0x95, 0xef, 0xe0, 0xcb, 0xb0, - 0x64, 0xe9, 0xca, 0x52, 0xd8, 0xfa, 0x10, 0x56, 0xff, 0x4c, 0x26, 0xfe, 0xe1, 0x2a, 0xd3, 0xe7, - 0x9e, 0x7b, 0xd2, 0xf7, 0x9e, 0x53, 0x8d, 0x36, 0x68, 0x37, 0x6a, 0xa7, 0x34, 0xe9, 0xa9, 0x28, - 0xa5, 0xc0, 0x94, 0x6c, 0xa7, 0x51, 0xde, 0x1e, 0xec, 0xe8, 0x1f, 0x3f, 0x17, 0x5c, 0x71, 0x7c, - 0x9b, 0x76, 0x23, 0x7f, 0x9c, 0xe2, 0xeb, 0xda, 0x60, 0x67, 0x65, 0x31, 0xe1, 0x09, 0x37, 0x9c, - 0xb6, 0xfe, 0xb2, 0xf4, 0x95, 0x35, 0xad, 0x18, 0x71, 0x01, 0x6d, 0x4b, 0xd7, 0x62, 0xf6, 0xcb, - 0x12, 0x5a, 0x27, 0xe8, 0xd6, 0x9b, 0x3c, 0x26, 0x0a, 0xf6, 0x0c, 0x7a, 0x00, 0x52, 0x92, 0x04, - 0xf0, 0x26, 0x9a, 0xcf, 0x05, 0x3f, 0x1f, 0x86, 0x99, 0x05, 0x9a, 0xd5, 0xf5, 0xea, 0x56, 0x23, - 0x68, 0x18, 0xb0, 0x20, 0x79, 0x08, 0x49, 0x9a, 0x30, 0xa2, 0xfa, 0x02, 0x64, 0x73, 0x62, 0x7d, - 0x72, 0xab, 0x11, 0x8c, 0x21, 0xad, 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0xa0, 0x04, 0xf0, 0x3d, - 0xb4, 0x70, 0x0a, 0xc3, 0x10, 0xce, 0x73, 0x2a, 0x88, 0xa2, 0x9c, 0x19, 0xcb, 0x6a, 0xc1, 0xfc, - 0x29, 0x0c, 0xf7, 0x47, 0xa0, 0x36, 0xfb, 0xad, 0xe0, 0xef, 0x81, 0x99, 0x99, 0x67, 0x03, 0x77, - 0xc2, 0xfb, 0x68, 0x3e, 0x25, 0x0a, 0xa4, 0x0a, 0x7b, 0xa0, 0x43, 0x6d, 0xa6, 0x98, 0x7b, 0xb8, - 0xe2, 0xeb, 0x98, 0xeb, 0xdc, 0xfa, 0x2e, 0xad, 0x83, 0x1d, 0xff, 0x85, 0x61, 0xec, 0xd6, 0x2e, - 0xbe, 0xac, 0x55, 0x82, 0x86, 0x6d, 0xb3, 0x18, 0x7e, 0x8c, 0x96, 0x48, 0x9a, 0xf2, 0x33, 0x88, - 0xc3, 0x77, 0x7d, 0xae, 0x20, 0x94, 0x8a, 0xa8, 0xbe, 0x74, 0xf3, 0xd5, 0x83, 0x45, 0x57, 0x7d, - 0xad, 0x8b, 0x47, 0xae, 0x86, 0x1f, 0xa0, 0x02, 0x0f, 0x49, 0x3c, 0xa0, 0x92, 0x8b, 0x61, 0x48, - 0x63, 0xd9, 0x9c, 0x36, 0x3d, 0xd8, 0xd5, 0x9e, 0xba, 0x52, 0x27, 0x96, 0x7a, 0x17, 0xa5, 0xed, - 0x33, 0x66, 0x75, 0x25, 0x80, 0xef, 0xa3, 0xff, 0x4a, 0x93, 0x6c, 0x70, 0x66, 0xcd, 0x32, 0x16, - 0x46, 0xf0, 0xa1, 0x49, 0xd0, 0x2e, 0x5a, 0xbd, 0x39, 0x18, 0x75, 0xd3, 0x76, 0x87, 0xdf, 0x90, - 0x8a, 0xe7, 0x68, 0xed, 0x5f, 0x89, 0x40, 0x46, 0x65, 0x95, 0xdf, 0x14, 0x87, 0x56, 0x07, 0x2d, - 0xec, 0x71, 0x26, 0x81, 0xc9, 0xbe, 0xb4, 0x86, 0x2f, 0xa3, 0x59, 0xbd, 0x3e, 0x08, 0x69, 0xec, - 0xfc, 0x9e, 0x31, 0xe7, 0x4e, 0xac, 0xe7, 0x57, 0x34, 0x03, 0xa9, 0x48, 0x96, 0x3b, 0xa3, 0x4b, - 0x60, 0xf7, 0xf8, 0xe2, 0x9b, 0x57, 0xb9, 0xb8, 0xf2, 0xaa, 0x97, 0x57, 0x5e, 0xf5, 0xeb, 0x95, - 0x57, 0xfd, 0x78, 0xed, 0x55, 0x2e, 0xaf, 0xbd, 0xca, 0xe7, 0x6b, 0xaf, 0x72, 0xf2, 0x24, 0xa1, - 0xaa, 0xd7, 0xef, 0xfa, 0x11, 0xcf, 0xda, 0x31, 0x51, 0x24, 0xea, 0x11, 0xca, 0x52, 0xd2, 0xd5, - 0x8f, 0xdb, 0x76, 0xc2, 0xed, 0xbb, 0xb7, 0x3d, 0xfe, 0xf0, 0xa9, 0x61, 0x0e, 0xb2, 0x3b, 0x6d, - 0x1e, 0xaa, 0x47, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x93, 0x8f, 0x19, 0x1d, 0x05, 0x00, - 0x00, + // 670 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x5d, 0x4f, 0x13, 0x4d, + 0x18, 0x6d, 0xa1, 0x7c, 0x0d, 0x85, 0x37, 0xef, 0x48, 0xb0, 0xa0, 0x2c, 0x50, 0x62, 0xe4, 0x86, + 0xad, 0xa8, 0xf1, 0x5e, 0x10, 0x63, 0x63, 0xc0, 0xb8, 0xe0, 0x0d, 0x37, 0x9b, 0xe9, 0xee, 0xe3, + 0x76, 0xc2, 0xee, 0xcc, 0x3a, 0x33, 0x2d, 0xd4, 0xff, 0x60, 0xe2, 0x7f, 0xf0, 0xcf, 0x70, 0xc9, + 0xa5, 0x57, 0x46, 0xe1, 0xd6, 0x1f, 0x61, 0xe6, 0x63, 0xbb, 0xf5, 0xab, 0x5e, 0xb5, 0x73, 0xce, + 0x99, 0x93, 0x7d, 0x9e, 0x73, 0x32, 0x68, 0x93, 0x76, 0xa2, 0x56, 0x4a, 0x93, 0xae, 0x8a, 0x52, + 0x0a, 0x4c, 0xc9, 0x56, 0x1a, 0xe5, 0xad, 0xfe, 0xae, 0xfe, 0xf1, 0x73, 0xc1, 0x15, 0xc7, 0xb7, + 0x69, 0x27, 0xf2, 0x47, 0x25, 0xbe, 0xe6, 0xfa, 0xbb, 0xab, 0x4b, 0x09, 0x4f, 0xb8, 0xd1, 0xb4, + 0xf4, 0x3f, 0x2b, 0x5f, 0x5d, 0xd7, 0x8e, 0x11, 0x17, 0xd0, 0xb2, 0x72, 0x6d, 0x66, 0xff, 0x59, + 0x41, 0xf3, 0x14, 0xdd, 0x7a, 0x93, 0xc7, 0x44, 0xc1, 0xbe, 0x41, 0x0f, 0x41, 0x4a, 0x92, 0x00, + 0xde, 0x42, 0x0b, 0xb9, 0xe0, 0x17, 0x83, 0x30, 0xb3, 0x40, 0xa3, 0xba, 0x51, 0xdd, 0xae, 0x07, + 0x75, 0x03, 0x16, 0x22, 0x0f, 0x21, 0x49, 0x13, 0x46, 0x54, 0x4f, 0x80, 0x6c, 0x4c, 0x6c, 0x4c, + 0x6e, 0xd7, 0x83, 0x11, 0xa4, 0xf9, 0xa9, 0x8a, 0x56, 0x02, 0x48, 0xa8, 0x54, 0x20, 0x0e, 0x58, + 0x94, 0x92, 0x3e, 0xbc, 0x84, 0xe1, 0xed, 0x65, 0x34, 0x2d, 0x20, 0xe7, 0x42, 0x39, 0x6f, 0x77, + 0xc2, 0x77, 0xd1, 0xdc, 0xd0, 0xa3, 0x31, 0x61, 0xa8, 0x12, 0xc0, 0x9b, 0xa8, 0xae, 0x0f, 0x94, + 0x25, 0x61, 0x04, 0x42, 0x35, 0x26, 0x8d, 0x60, 0xde, 0x61, 0xfb, 0x20, 0x14, 0xde, 0x41, 0x98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x24, 0xa1, 0xaa, 0xdb, 0xeb, + 0xf8, 0x11, 0xcf, 0x5a, 0x31, 0x51, 0x24, 0xea, 0x12, 0xca, 0x52, 0xd2, 0xd1, 0x8f, 0xdb, 0x4e, + 0xc2, 0xed, 0xbb, 0xb7, 0x33, 0xfa, 0xf0, 0xa9, 0x41, 0x0e, 0xb2, 0x33, 0x6d, 0x1e, 0xaa, 0x47, + 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xb1, 0x44, 0x28, 0x1d, 0x05, 0x00, 0x00, } func (m *UpdateClientMessage) Marshal() (dAtA []byte, err error) { @@ -869,7 +868,7 @@ func (m *RegisterEnclaveKeyMessage) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Report", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLcp @@ -879,23 +878,25 @@ func (m *RegisterEnclaveKeyMessage) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthLcp } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthLcp } if postIndex > l { return io.ErrUnexpectedEOF } - m.Report = string(dAtA[iNdEx:postIndex]) + m.Report = append(m.Report[:0], dAtA[iNdEx:postIndex]...) + if m.Report == nil { + m.Report = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { diff --git a/light-clients/lcp/types/update.go b/light-clients/lcp/types/update.go index 51f57e9..f62eb36 100644 --- a/light-clients/lcp/types/update.go +++ b/light-clients/lcp/types/update.go @@ -121,7 +121,7 @@ func (cs ClientState) verifyRegisterEnclaveKey(ctx sdk.Context, store storetypes } var operator common.Address if len(message.OperatorSignature) > 0 { - commitment, err := ComputeEIP712RegisterEnclaveKeyHash(ctx.ChainID(), []byte(exported.StoreKey), message.Report) + commitment, err := ComputeEIP712RegisterEnclaveKeyHash(ctx.ChainID(), []byte(exported.StoreKey), string(message.Report)) if err != nil { return errorsmod.Wrapf(clienttypes.ErrInvalidHeader, "failed to compute commitment: %v", err) } @@ -246,7 +246,7 @@ func (cs ClientState) registerEnclaveKey(ctx sdk.Context, clientStore storetypes } var operator common.Address if len(message.OperatorSignature) > 0 { - commitment, err := ComputeEIP712RegisterEnclaveKeyHash(ctx.ChainID(), []byte(exported.StoreKey), message.Report) + commitment, err := ComputeEIP712RegisterEnclaveKeyHash(ctx.ChainID(), []byte(exported.StoreKey), string(message.Report)) if err != nil { panic(errorsmod.Wrapf(clienttypes.ErrInvalidHeader, "failed to compute commitment: %v", err)) } diff --git a/relay/lcp.go b/relay/lcp.go index 9bfb62a..75302db 100644 --- a/relay/lcp.go +++ b/relay/lcp.go @@ -218,10 +218,10 @@ func (pr *Prover) selectNewEnclaveKey(ctx context.Context) (*enclave.EnclaveKeyI } for _, eki := range res.Keys { - if err := ias.VerifyReport(eki.Report, eki.Signature, eki.SigningCert, time.Now()); err != nil { + if err := ias.VerifyReport([]byte(eki.Report), eki.Signature, eki.SigningCert, time.Now()); err != nil { return nil, err } - avr, err := ias.ParseAndValidateAVR(eki.Report) + avr, err := ias.ParseAndValidateAVR([]byte(eki.Report)) if err != nil { return nil, err } @@ -320,14 +320,14 @@ func (pr *Prover) updateELC(elcClientID string, includeState bool) ([]*elc.MsgUp func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKeyInfo) (core.MsgID, error) { clientLogger := pr.getClientLogger(pr.originChain.Path().ClientID) - if err := ias.VerifyReport(eki.Report, eki.Signature, eki.SigningCert, time.Now()); err != nil { + if err := ias.VerifyReport([]byte(eki.Report), eki.Signature, eki.SigningCert, time.Now()); err != nil { return nil, err } - if _, err := ias.ParseAndValidateAVR(eki.Report); err != nil { + if _, err := ias.ParseAndValidateAVR([]byte(eki.Report)); err != nil { return nil, err } message := &lcptypes.RegisterEnclaveKeyMessage{ - Report: eki.Report, + Report: []byte(eki.Report), Signature: eki.Signature, SigningCert: eki.SigningCert, OperatorSignature: nil, diff --git a/sgx/ias/sgx.go b/sgx/ias/sgx.go index 04dd067..aed13f7 100644 --- a/sgx/ias/sgx.go +++ b/sgx/ias/sgx.go @@ -27,7 +27,7 @@ func (avr AttestationVerificationReport) GetTimestamp() time.Time { return tm.Truncate(time.Second) } -func VerifyReport(report string, signature []byte, signingCertDer []byte, currentTime time.Time) error { +func VerifyReport(report []byte, signature []byte, signingCertDer []byte, currentTime time.Time) error { rootCert := GetRARootCert() signingCert, err := x509.ParseCertificate(signingCertDer) if err != nil { @@ -50,15 +50,15 @@ func VerifyReport(report string, signature []byte, signingCertDer []byte, curren return fmt.Errorf("unexpected root cert: %v", chains[0][1]) } - if err = signingCert.CheckSignature(x509.SHA256WithRSA, []byte(report), signature); err != nil { + if err = signingCert.CheckSignature(x509.SHA256WithRSA, report, signature); err != nil { return fmt.Errorf("failed to verify AVR signature: %w", err) } return nil } -func ParseAndValidateAVR(report string) (*AttestationVerificationReport, error) { - avr, err := ias.UnsafeDecodeAVR([]byte(report)) +func ParseAndValidateAVR(report []byte) (*AttestationVerificationReport, error) { + avr, err := ias.UnsafeDecodeAVR(report) if err != nil { return nil, err }