diff --git a/proto/relayer/provers/lcp/config/config.proto b/proto/relayer/provers/lcp/config/config.proto index 31faa3c..029e4d9 100644 --- a/proto/relayer/provers/lcp/config/config.proto +++ b/proto/relayer/provers/lcp/config/config.proto @@ -31,9 +31,9 @@ message ProverConfig { // this only works when operators is not empty // the value must be less than or equal to 1 Fraction operators_threshold = 13 [(gogoproto.nullable) = false]; - // TODO use signer module instead - // hex string - string operator_private_key = 14; + // signer for eip712 commitment + google.protobuf.Any operator_signer = 14; + // eip712 params oneof operators_eip712_params { EVMChainEIP712Params operators_evm_chain_eip712_params = 31; CosmosChainEIP712Params operators_cosmos_chain_eip712_params = 32; diff --git a/proto/relayer/provers/lcp/signers/raw/config.proto b/proto/relayer/provers/lcp/signers/raw/config.proto new file mode 100644 index 0000000..c675f49 --- /dev/null +++ b/proto/relayer/provers/lcp/signers/raw/config.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package relayer.provers.lcp.signers.raw; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/datachainlab/lcp-go/relay/signers/raw"; +option (gogoproto.goproto_getters_all) = false; + +message SignerConfig { + string private_key = 1; +} \ No newline at end of file diff --git a/relay/bin/main.go b/relay/bin/main.go index c0d17ea..a6bc4bd 100644 --- a/relay/bin/main.go +++ b/relay/bin/main.go @@ -4,6 +4,7 @@ import ( "log" lcp "github.com/datachainlab/lcp-go/relay" + "github.com/datachainlab/lcp-go/relay/signers/raw" lcptm "github.com/datachainlab/lcp-go/relay/tendermint" tendermint "github.com/hyperledger-labs/yui-relayer/chains/tendermint/module" "github.com/hyperledger-labs/yui-relayer/cmd" @@ -14,6 +15,7 @@ func main() { tendermint.Module{}, lcp.Module{}, lcptm.Module{}, + raw.Module{}, ); err != nil { log.Fatal(err) } diff --git a/relay/config.go b/relay/config.go index 59b2469..d1df9c9 100644 --- a/relay/config.go +++ b/relay/config.go @@ -10,6 +10,7 @@ import ( lcptypes "github.com/datachainlab/lcp-go/light-clients/lcp/types" "github.com/ethereum/go-ethereum/common" "github.com/hyperledger-labs/yui-relayer/core" + "github.com/hyperledger-labs/yui-relayer/signer" ) const ( @@ -48,6 +49,11 @@ func (cfg *ProverConfig) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error if err := unpacker.UnpackAny(cfg.OriginProver, new(core.ProverConfig)); err != nil { return err } + if cfg.OperatorSigner != nil { + if err := unpacker.UnpackAny(cfg.OperatorSigner, new(signer.SignerConfig)); err != nil { + return err + } + } return nil } @@ -121,8 +127,14 @@ func (pc ProverConfig) Validate() error { return fmt.Errorf("Operators: currently only one or zero(=permissionless) operator is supported, but got %v", l) } if pc.OperatorsEip712Params != nil { - if len(pc.OperatorPrivateKey) == 0 { - return fmt.Errorf("OperatorPrivateKey must be set if OperatorsEip712Salt is set") + if pc.OperatorSigner == nil { + return fmt.Errorf("OperatorSigner must be set if OperatorsEip712Params is set") + } + signerConfig, ok := pc.OperatorSigner.GetCachedValue().(signer.SignerConfig) + if !ok { + return fmt.Errorf("failed to cast OperatorSigner's config: %T", pc.OperatorSigner.GetCachedValue()) + } else if err := signerConfig.Validate(); err != nil { + return fmt.Errorf("failed to validate the OperatorSigner's config: %v", err) } switch salt := pc.OperatorsEip712Params.(type) { case *ProverConfig_OperatorsEvmChainEip712Params: @@ -146,10 +158,6 @@ func (pc ProverConfig) Validate() error { return nil } -func (f Fraction) String() string { - return fmt.Sprintf("%v/%v", f.Numerator, f.Denominator) -} - func decodeMrenclaveHex(s string) ([]byte, error) { trimmed := strings.ToLower(strings.TrimPrefix(s, "0x")) bz, err := hex.DecodeString(trimmed) diff --git a/relay/config.pb.go b/relay/config.pb.go index 8096e90..e8d31db 100644 --- a/relay/config.pb.go +++ b/relay/config.pb.go @@ -47,9 +47,10 @@ type ProverConfig struct { // this only works when operators is not empty // the value must be less than or equal to 1 OperatorsThreshold Fraction `protobuf:"bytes,13,opt,name=operators_threshold,json=operatorsThreshold,proto3" json:"operators_threshold"` - // TODO use signer module instead - // hex string - OperatorPrivateKey string `protobuf:"bytes,14,opt,name=operator_private_key,json=operatorPrivateKey,proto3" json:"operator_private_key,omitempty"` + // signer for eip712 commitment + OperatorSigner *types.Any `protobuf:"bytes,14,opt,name=operator_signer,json=operatorSigner,proto3" json:"operator_signer,omitempty"` + // eip712 params + // // Types that are valid to be assigned to OperatorsEip712Params: // *ProverConfig_OperatorsEvmChainEip712Params // *ProverConfig_OperatorsCosmosChainEip712Params @@ -260,56 +261,55 @@ func init() { } var fileDescriptor_2e6956e1b8ef896e = []byte{ - // 771 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0x8e, 0x77, 0x4b, 0xdb, 0x4c, 0x3f, 0x04, 0xd3, 0xb2, 0xeb, 0x96, 0xc5, 0x6b, 0xa2, 0x22, - 0x72, 0xc1, 0xde, 0xed, 0x22, 0x55, 0x48, 0x5c, 0xda, 0x6c, 0x10, 0xe1, 0x43, 0x0a, 0xee, 0x8a, - 0x03, 0x1c, 0x46, 0x93, 0xf1, 0x1b, 0x67, 0xd4, 0xb1, 0xc7, 0xcc, 0x38, 0x66, 0xbd, 0xe2, 0xca, - 0x9d, 0x9f, 0xd5, 0xe3, 0x1e, 0x39, 0x21, 0x68, 0x7f, 0x01, 0xff, 0x00, 0x79, 0xc6, 0x89, 0xa3, - 0xdd, 0x6c, 0x4f, 0xc9, 0x3c, 0x5f, 0xef, 0x93, 0xd7, 0xce, 0xa0, 0xcf, 0x14, 0x08, 0x5a, 0x81, - 0x0a, 0x73, 0x25, 0x4b, 0x50, 0x3a, 0x14, 0x2c, 0x0f, 0x99, 0xcc, 0xa6, 0x3c, 0x69, 0x3e, 0x82, - 0x5c, 0xc9, 0x42, 0xe2, 0xe3, 0x46, 0x18, 0x34, 0xc2, 0x40, 0xb0, 0x3c, 0xb0, 0x8a, 0xe3, 0xc3, - 0x44, 0x26, 0xd2, 0xc8, 0xc2, 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x3d, 0x7c, 0xc7, 0x5a, 0xde, 0x9a, 0xd9, 0x6d, 0x67, 0x3e, - 0x40, 0x9b, 0xb9, 0x82, 0x29, 0x7f, 0xd9, 0xe4, 0x37, 0xa7, 0x8b, 0x8b, 0xeb, 0x7f, 0xbd, 0xce, - 0xf5, 0x8d, 0xe7, 0xbc, 0xbe, 0xf1, 0x9c, 0x7f, 0x6e, 0x3c, 0xe7, 0xcf, 0x5b, 0xaf, 0xf3, 0xfa, - 0xd6, 0xeb, 0xfc, 0x75, 0xeb, 0x75, 0x7e, 0x3e, 0x49, 0x78, 0x31, 0x9b, 0x4f, 0x02, 0x26, 0xd3, - 0x30, 0xa6, 0x05, 0x35, 0x69, 0x82, 0x4e, 0xea, 0xab, 0xf9, 0xf3, 0x44, 0x86, 0xe6, 0xd1, 0x4d, - 0x36, 0xcd, 0x95, 0xf8, 0xec, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xc9, 0xa7, 0x42, 0xc1, - 0x05, 0x00, 0x00, + // 768 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x41, 0x8f, 0xdb, 0x44, + 0x14, 0x8e, 0xdb, 0x65, 0x37, 0x99, 0x6c, 0x02, 0xcc, 0x86, 0xd6, 0x1b, 0x8a, 0x6b, 0xa2, 0x45, + 0xe4, 0x82, 0xdd, 0x6e, 0x91, 0x56, 0x48, 0x70, 0x48, 0xd2, 0x20, 0x82, 0x40, 0x5a, 0x9c, 0x8a, + 0x03, 0x1c, 0x46, 0x93, 0xf1, 0x8b, 0x33, 0xea, 0xd8, 0x63, 0x66, 0x9c, 0xd0, 0x54, 0x5c, 0xb9, + 0xf3, 0xb3, 0xf6, 0xd8, 0x23, 0x27, 0x04, 0xbb, 0xff, 0x03, 0x21, 0x8f, 0x9d, 0x38, 0xa2, 0xd9, + 0x3d, 0x25, 0xf3, 0x7d, 0xdf, 0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 0x49, 0xd4, 0xd9, 0x37, 0x27, 0x7c, 0x8a, 0xea, 0xc5, 0x8f, + 0xe6, 0x61, 0x69, 0x7b, 0x64, 0xce, 0x93, 0x10, 0x7f, 0x89, 0xba, 0x2b, 0x50, 0x7c, 0xbe, 0xe6, + 0x49, 0x44, 0x98, 0x4c, 0xb2, 0x3c, 0xcb, 0xff, 0x9e, 0x0e, 0x7b, 0xab, 0x18, 0x95, 0x82, 0xf2, + 0x05, 0xe9, 0x7d, 0x87, 0x1e, 0xde, 0x32, 0x96, 0xb7, 0x7a, 0x36, 0xaa, 0x9e, 0x0f, 0xd0, 0x61, + 0xaa, 0x60, 0xce, 0x5f, 0x95, 0xfe, 0xe5, 0x69, 0x38, 0xbc, 0xfa, 0xc7, 0xa9, 0x5d, 0x5d, 0x3b, + 0xd6, 0x9b, 0x6b, 0xc7, 0xfa, 0xfb, 0xda, 0xb1, 0xfe, 0xb8, 0x71, 0x6a, 0x6f, 0x6e, 0x9c, 0xda, + 0x9f, 0x37, 0x4e, 0xed, 0xa7, 0xb3, 0x88, 0x67, 0x8b, 0xe5, 0xcc, 0x63, 0x32, 0xf6, 0x43, 0x9a, + 0x51, 0xe3, 0x26, 0xe8, 0x2c, 0x7f, 0xa7, 0x3f, 0x8b, 0xa4, 0x6f, 0xae, 0x6e, 0x76, 0x68, 0xb6, + 0xf1, 0xd9, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xdd, 0x8c, 0x1a, 0xce, 0x05, 0x00, 0x00, } func (m *ProverConfig) Marshal() (dAtA []byte, err error) { @@ -341,10 +341,15 @@ func (m *ProverConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } } - if len(m.OperatorPrivateKey) > 0 { - i -= len(m.OperatorPrivateKey) - copy(dAtA[i:], m.OperatorPrivateKey) - i = encodeVarintConfig(dAtA, i, uint64(len(m.OperatorPrivateKey))) + if m.OperatorSigner != nil { + { + size, err := m.OperatorSigner.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x72 } @@ -675,8 +680,8 @@ func (m *ProverConfig) Size() (n int) { } l = m.OperatorsThreshold.Size() n += 1 + l + sovConfig(uint64(l)) - l = len(m.OperatorPrivateKey) - if l > 0 { + if m.OperatorSigner != nil { + l = m.OperatorSigner.Size() n += 1 + l + sovConfig(uint64(l)) } if m.OperatorsEip712Params != nil { @@ -1152,9 +1157,9 @@ func (m *ProverConfig) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 14: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorPrivateKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorSigner", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConfig @@ -1164,23 +1169,27 @@ func (m *ProverConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthConfig } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthConfig } if postIndex > l { return io.ErrUnexpectedEOF } - m.OperatorPrivateKey = string(dAtA[iNdEx:postIndex]) + if m.OperatorSigner == nil { + m.OperatorSigner = &types.Any{} + } + if err := m.OperatorSigner.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 31: if wireType != 2 { diff --git a/relay/lcp.go b/relay/lcp.go index 4f9431c..5d4a50c 100644 --- a/relay/lcp.go +++ b/relay/lcp.go @@ -342,7 +342,7 @@ func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKe if err != nil { return nil, err } - sig, err := pr.OperatorSign(commitment) + sig, err := pr.eip712Signer.Sign(commitment) if err != nil { return nil, err } diff --git a/relay/operator.go b/relay/operator.go index 044d016..caceb1a 100644 --- a/relay/operator.go +++ b/relay/operator.go @@ -3,8 +3,6 @@ package relay import ( "bytes" "context" - "crypto/ecdsa" - "encoding/hex" "fmt" "strings" @@ -14,37 +12,12 @@ import ( lcptypes "github.com/datachainlab/lcp-go/light-clients/lcp/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/hyperledger-labs/yui-relayer/core" + "github.com/hyperledger-labs/yui-relayer/signer" ) -func (pr *Prover) OperatorSign(commitment [32]byte) ([]byte, error) { - privKey, err := pr.getOperatorPrivateKey() - if err != nil { - return nil, err - } - return secp256k1.Sign(commitment[:], privKey) -} - -func (pr *Prover) GetSignOperator() (common.Address, error) { - privKey, err := pr.getOperatorPrivateKey() - if err != nil { - return common.Address{}, err - } - pk, err := crypto.ToECDSA(privKey) - if err != nil { - return common.Address{}, err - } - pubKey := pk.Public().(*ecdsa.PublicKey) - return common.BytesToAddress(crypto.PubkeyToAddress(*pubKey).Bytes()), nil -} - -func (pr *Prover) getOperatorPrivateKey() ([]byte, error) { - return hex.DecodeString(strings.TrimPrefix(pr.config.OperatorPrivateKey, "0x")) -} - func (pr *Prover) IsOperatorEnabled() bool { - return len(pr.config.OperatorPrivateKey) > 0 && pr.config.OperatorsEip712Params != nil + return pr.eip712Signer != nil && pr.config.OperatorsEip712Params != nil } func (pr *Prover) GetOperators() ([]common.Address, error) { @@ -71,9 +44,12 @@ func (pr *Prover) updateOperators(counterparty core.Chain, nonce uint64, newOper if nonce == 0 { return fmt.Errorf("invalid nonce: %v", nonce) } - if threshold.Numerator == 0 || threshold.Denominator == 0 || threshold.Numerator > threshold.Denominator { + if threshold.Numerator == 0 || threshold.Denominator == 0 { return fmt.Errorf("invalid threshold: %s", threshold.String()) } + if threshold.Numerator > threshold.Denominator { + return fmt.Errorf("new operators threshold numerator cannot be greater than denominator: %s", threshold.String()) + } cplatestHeight, err := counterparty.LatestHeight() if err != nil { return err @@ -95,7 +71,7 @@ func (pr *Prover) updateOperators(counterparty core.Chain, nonce uint64, newOper } else if l > 1 { return fmt.Errorf("currently only one operator is supported, but got %v", l) } - opSigner, err := pr.GetSignOperator() + opSigner, err := pr.eip712Signer.GetSignerAddress() if err != nil { return err } @@ -111,7 +87,7 @@ func (pr *Prover) updateOperators(counterparty core.Chain, nonce uint64, newOper if err != nil { return err } - sig, err := pr.OperatorSign(commitment) + sig, err := pr.eip712Signer.Sign(commitment) if err != nil { return err } @@ -139,3 +115,27 @@ func (pr *Prover) updateOperators(counterparty core.Chain, nonce uint64, newOper } return nil } + +type EIP712Signer struct { + signer signer.Signer +} + +func NewEIP712Signer(signer signer.Signer) *EIP712Signer { + return &EIP712Signer{signer: signer} +} + +func (s EIP712Signer) Sign(commitment [32]byte) ([]byte, error) { + return s.signer.Sign(commitment[:]) +} + +func (s EIP712Signer) GetSignerAddress() (common.Address, error) { + pub, err := s.signer.GetPublicKey() + if err != nil { + return common.Address{}, err + } + pubKey, err := crypto.DecompressPubkey(pub) + if err != nil { + return common.Address{}, err + } + return crypto.PubkeyToAddress(*pubKey), nil +} diff --git a/relay/prover.go b/relay/prover.go index 26eca5c..c771c22 100644 --- a/relay/prover.go +++ b/relay/prover.go @@ -15,6 +15,7 @@ import ( "github.com/datachainlab/lcp-go/sgx/ias" "github.com/hyperledger-labs/yui-relayer/core" "github.com/hyperledger-labs/yui-relayer/log" + "github.com/hyperledger-labs/yui-relayer/signer" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -30,6 +31,8 @@ type Prover struct { lcpServiceClient LCPServiceClient + eip712Signer *EIP712Signer + // state // registered key info for requesting lcp to generate proof. activeEnclaveKey *enclave.EnclaveKeyInfo @@ -52,7 +55,15 @@ func NewProver(config ProverConfig, originChain core.Chain, originProver core.Pr if err != nil { return nil, fmt.Errorf("failed to connect to LCP service: %w", err) } - return &Prover{config: config, originChain: originChain, originProver: originProver, lcpServiceClient: NewLCPServiceClient(conn)}, nil + var eip712Signer *EIP712Signer + if config.OperatorSigner != nil { + signer, err := config.OperatorSigner.GetCachedValue().(signer.SignerConfig).Build() + if err != nil { + return nil, err + } + eip712Signer = NewEIP712Signer(signer) + } + return &Prover{config: config, originChain: originChain, originProver: originProver, lcpServiceClient: NewLCPServiceClient(conn), eip712Signer: eip712Signer}, nil } func (pr *Prover) GetOriginProver() core.Prover { diff --git a/relay/signers/raw/config.go b/relay/signers/raw/config.go new file mode 100644 index 0000000..1145558 --- /dev/null +++ b/relay/signers/raw/config.go @@ -0,0 +1,31 @@ +package raw + +import ( + "encoding/hex" + fmt "fmt" + "strings" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/hyperledger-labs/yui-relayer/signer" +) + +var _ signer.SignerConfig = (*SignerConfig)(nil) + +func (c *SignerConfig) Validate() error { + if _, err := hex.DecodeString(strings.TrimPrefix(c.PrivateKey, "0x")); err != nil { + return fmt.Errorf("invalid private key: %w", err) + } + return nil +} + +func (c *SignerConfig) Build() (signer.Signer, error) { + bz, err := hex.DecodeString(strings.TrimPrefix(c.PrivateKey, "0x")) + if err != nil { + return nil, fmt.Errorf("failed to decode private key: %w", err) + } + privKey, err := crypto.ToECDSA(bz) + if err != nil { + return nil, fmt.Errorf("failed to decode to ECDSA: %w", err) + } + return NewSigner(privKey), nil +} diff --git a/relay/signers/raw/config.pb.go b/relay/signers/raw/config.pb.go new file mode 100644 index 0000000..88a5dc6 --- /dev/null +++ b/relay/signers/raw/config.pb.go @@ -0,0 +1,314 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: relayer/provers/lcp/signers/raw/config.proto + +package raw + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// 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 + +type SignerConfig struct { + PrivateKey string `protobuf:"bytes,1,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` +} + +func (m *SignerConfig) Reset() { *m = SignerConfig{} } +func (m *SignerConfig) String() string { return proto.CompactTextString(m) } +func (*SignerConfig) ProtoMessage() {} +func (*SignerConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_92339b430a08f7d7, []int{0} +} +func (m *SignerConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignerConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignerConfig.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignerConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignerConfig.Merge(m, src) +} +func (m *SignerConfig) XXX_Size() int { + return m.Size() +} +func (m *SignerConfig) XXX_DiscardUnknown() { + xxx_messageInfo_SignerConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_SignerConfig proto.InternalMessageInfo + +func init() { + proto.RegisterType((*SignerConfig)(nil), "relayer.provers.lcp.signers.raw.SignerConfig") +} + +func init() { + proto.RegisterFile("relayer/provers/lcp/signers/raw/config.proto", fileDescriptor_92339b430a08f7d7) +} + +var fileDescriptor_92339b430a08f7d7 = []byte{ + // 209 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x29, 0x4a, 0xcd, 0x49, + 0xac, 0x4c, 0x2d, 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0x4b, 0x2d, 0x2a, 0xd6, 0xcf, 0x49, 0x2e, 0xd0, + 0x2f, 0xce, 0x4c, 0xcf, 0x03, 0xb1, 0x8b, 0x12, 0xcb, 0xf5, 0x93, 0xf3, 0xf3, 0xd2, 0x32, 0xd3, + 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xe4, 0xa1, 0xaa, 0xf5, 0xa0, 0xaa, 0xf5, 0x72, 0x92, + 0x0b, 0xf4, 0xa0, 0xaa, 0xf5, 0x8a, 0x12, 0xcb, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x6a, + 0xf5, 0x41, 0x2c, 0x88, 0x36, 0x25, 0x7d, 0x2e, 0x9e, 0x60, 0xb0, 0x22, 0x67, 0xb0, 0x61, 0x42, + 0xf2, 0x5c, 0xdc, 0x05, 0x45, 0x99, 0x65, 0x89, 0x25, 0xa9, 0xf1, 0xd9, 0xa9, 0x95, 0x12, 0x8c, + 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x5c, 0x50, 0x21, 0xef, 0xd4, 0x4a, 0x27, 0xbf, 0x13, 0x0f, 0xe5, + 0x18, 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, 0xca, 0x20, 0x3d, 0xb3, 0x24, + 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x25, 0xb1, 0x24, 0x31, 0x39, 0x23, 0x31, 0x33, + 0x2f, 0x27, 0x31, 0x09, 0xe4, 0x76, 0xdd, 0xf4, 0x7c, 0x7d, 0xb0, 0x23, 0x91, 0x3d, 0x91, 0xc4, + 0x06, 0x76, 0x87, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x44, 0xa2, 0x5e, 0xec, 0xee, 0x00, 0x00, + 0x00, +} + +func (m *SignerConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignerConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignerConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PrivateKey) > 0 { + i -= len(m.PrivateKey) + copy(dAtA[i:], m.PrivateKey) + i = encodeVarintConfig(dAtA, i, uint64(len(m.PrivateKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintConfig(dAtA []byte, offset int, v uint64) int { + offset -= sovConfig(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SignerConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PrivateKey) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + return n +} + +func sovConfig(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConfig(x uint64) (n int) { + return sovConfig(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SignerConfig) Unmarshal(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 ErrIntOverflowConfig + } + 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: SignerConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignerConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrivateKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrivateKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConfig(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 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthConfig + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConfig + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConfig + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConfig = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfig = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfig = fmt.Errorf("proto: unexpected end of group") +) diff --git a/relay/signers/raw/module.go b/relay/signers/raw/module.go new file mode 100644 index 0000000..954ff22 --- /dev/null +++ b/relay/signers/raw/module.go @@ -0,0 +1,32 @@ +package raw + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/hyperledger-labs/yui-relayer/config" + "github.com/hyperledger-labs/yui-relayer/signer" + "github.com/spf13/cobra" +) + +type Module struct{} + +var _ config.ModuleI = (*Module)(nil) + +const ModuleName = "lcp.signers.raw" + +// Name returns the name of the module +func (Module) Name() string { + return ModuleName +} + +// RegisterInterfaces registers the module interfaces to protobuf Any. +func (Module) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*signer.SignerConfig)(nil), + &SignerConfig{}, + ) +} + +// GetCmd returns the command +func (Module) GetCmd(ctx *config.Context) *cobra.Command { + return nil +} diff --git a/relay/signers/raw/signer.go b/relay/signers/raw/signer.go new file mode 100644 index 0000000..775c180 --- /dev/null +++ b/relay/signers/raw/signer.go @@ -0,0 +1,34 @@ +package raw + +import ( + "crypto/ecdsa" + "fmt" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/hyperledger-labs/yui-relayer/signer" +) + +var _ signer.Signer = (*Signer)(nil) + +type Signer struct { + privKey *ecdsa.PrivateKey +} + +func NewSigner(privKey *ecdsa.PrivateKey) *Signer { + return &Signer{ + privKey: privKey, + } +} + +func (s *Signer) GetPublicKey() ([]byte, error) { + return crypto.CompressPubkey(&s.privKey.PublicKey), nil +} + +func (s *Signer) Sign(digest []byte) ([]byte, error) { + sig, err := crypto.Sign(digest, s.privKey) + if err != nil { + return nil, fmt.Errorf("failed to sign tx: %v", err) + } + + return sig, nil +} diff --git a/tests/e2e/cases/tm2tm/configs/templates/ibc-0-operators.json.tpl b/tests/e2e/cases/tm2tm/configs/templates/ibc-0-operators.json.tpl index ab46150..5e19868 100644 --- a/tests/e2e/cases/tm2tm/configs/templates/ibc-0-operators.json.tpl +++ b/tests/e2e/cases/tm2tm/configs/templates/ibc-0-operators.json.tpl @@ -34,6 +34,9 @@ "chain_id": "ibc1", "prefix": "ibc" }, - "operator_private_key": "0x99b107441d0bce8e5b0078450f10f309910d8c0a2cc91671bd6cc1a284809642" + "operator_signer": { + "@type": "/relayer.provers.lcp.signers.raw.SignerConfig", + "private_key": "0x99b107441d0bce8e5b0078450f10f309910d8c0a2cc91671bd6cc1a284809642" + } } } diff --git a/tests/e2e/cases/tm2tm/configs/templates/ibc-1-operators.json.tpl b/tests/e2e/cases/tm2tm/configs/templates/ibc-1-operators.json.tpl index 0a8e2a0..d75f7a5 100644 --- a/tests/e2e/cases/tm2tm/configs/templates/ibc-1-operators.json.tpl +++ b/tests/e2e/cases/tm2tm/configs/templates/ibc-1-operators.json.tpl @@ -34,6 +34,9 @@ "chain_id": "ibc0", "prefix": "ibc" }, - "operator_private_key": "0x8a94e9f944a297c402a997aa9a60026ce47a6e018192d111c1703176bbc26651" + "operator_signer": { + "@type": "/relayer.provers.lcp.signers.raw.SignerConfig", + "private_key": "0x8a94e9f944a297c402a997aa9a60026ce47a6e018192d111c1703176bbc26651" + } } }