diff --git a/lnrpc/signrpc/signer.pb.go b/lnrpc/signrpc/signer.pb.go index 8e78c8a9..75e7ff7d 100644 --- a/lnrpc/signrpc/signer.pb.go +++ b/lnrpc/signrpc/signer.pb.go @@ -673,12 +673,18 @@ type SharedKeyRequest struct { // The ephemeral public key to use for the DH key derivation. EphemeralPubkey []byte `protobuf:"bytes,1,opt,name=ephemeral_pubkey,json=ephemeralPubkey,proto3" json:"ephemeral_pubkey,omitempty"` // - //The optional key locator of the local key that should be used. If this - //parameter is not set then the node's identity private key will be used. - KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc,proto3" json:"key_loc,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + //Deprecated. The optional key locator of the local key that should be used. + //If this parameter is not set then the node's identity private key will be + //used. + KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc,proto3" json:"key_loc,omitempty"` // Deprecated: Do not use. + // + //A key descriptor describes the key used for performing ECDH. Either a key + //locator or a raw public key is expected, if neither is supplied, defaults to + //the node's identity private key. + KeyDesc *KeyDescriptor `protobuf:"bytes,3,opt,name=key_desc,json=keyDesc,proto3" json:"key_desc,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SharedKeyRequest) Reset() { *m = SharedKeyRequest{} } @@ -713,6 +719,7 @@ func (m *SharedKeyRequest) GetEphemeralPubkey() []byte { return nil } +// Deprecated: Do not use. func (m *SharedKeyRequest) GetKeyLoc() *KeyLocator { if m != nil { return m.KeyLoc @@ -720,6 +727,13 @@ func (m *SharedKeyRequest) GetKeyLoc() *KeyLocator { return nil } +func (m *SharedKeyRequest) GetKeyDesc() *KeyDescriptor { + if m != nil { + return m.KeyDesc + } + return nil +} + type SharedKeyResponse struct { // The shared public key, hashed with sha256. SharedKey []byte `protobuf:"bytes,1,opt,name=shared_key,json=sharedKey,proto3" json:"shared_key,omitempty"` @@ -780,55 +794,56 @@ func init() { func init() { proto.RegisterFile("signrpc/signer.proto", fileDescriptor_4ecd772f6c7ffacf) } var fileDescriptor_4ecd772f6c7ffacf = []byte{ - // 756 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x5d, 0x8f, 0xdb, 0x44, - 0x14, 0xd5, 0x26, 0x6c, 0x92, 0xbd, 0x4e, 0x76, 0xb3, 0xc3, 0xaa, 0xb8, 0x0b, 0x88, 0x60, 0xa9, - 0x28, 0x95, 0x20, 0x11, 0x01, 0x21, 0xc1, 0x13, 0x2a, 0xd5, 0xaa, 0x55, 0x8a, 0x5a, 0x39, 0x2b, - 0x1e, 0xfa, 0x62, 0x39, 0xce, 0xad, 0x33, 0xb2, 0x63, 0xcf, 0xce, 0x8c, 0xeb, 0xf8, 0x77, 0xf0, - 0xd7, 0xf8, 0x41, 0x68, 0x3e, 0xe2, 0xd8, 0x29, 0x54, 0xea, 0xd3, 0xfa, 0x9e, 0xb9, 0x73, 0xee, - 0xd9, 0x73, 0xae, 0x63, 0xb8, 0x11, 0x34, 0xce, 0x38, 0x8b, 0xe6, 0xea, 0x2f, 0xf2, 0x19, 0xe3, - 0xb9, 0xcc, 0x49, 0xdf, 0xa2, 0xde, 0x0b, 0x80, 0x25, 0x56, 0xaf, 0xf2, 0x28, 0x94, 0x39, 0x27, - 0x5f, 0x03, 0x24, 0x58, 0x05, 0xef, 0xc2, 0x1d, 0x4d, 0x2b, 0xf7, 0x6c, 0x72, 0x36, 0x3d, 0xf7, - 0x2f, 0x12, 0xac, 0xee, 0x34, 0x40, 0xbe, 0x04, 0x55, 0x04, 0x34, 0xdb, 0xe0, 0xde, 0xed, 0xe8, - 0xd3, 0x41, 0x82, 0xd5, 0x4b, 0x55, 0x7b, 0x21, 0x8c, 0x96, 0x58, 0x3d, 0x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e6, 0x6f, 0x7f, 0x88, 0xa9, 0xdc, 0x16, 0xeb, 0x59, 0x94, 0xef, 0xe6, 0x29, 0x8d, 0xb7, 0x32, - 0xa3, 0x59, 0x9c, 0xa1, 0x2c, 0x73, 0x9e, 0xcc, 0xd3, 0x6c, 0x33, 0x4f, 0xeb, 0x2f, 0x0c, 0x67, - 0xd1, 0xba, 0xa7, 0xbf, 0x31, 0x3f, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x73, 0xb0, 0xe9, 0x51, - 0x7b, 0x06, 0x00, 0x00, + // 775 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xed, 0x8e, 0xdb, 0x44, + 0x14, 0x55, 0x12, 0x36, 0xc9, 0x5e, 0x27, 0xbb, 0xd9, 0x61, 0x55, 0xdc, 0x05, 0xc4, 0x62, 0xa9, + 0x68, 0x2b, 0x41, 0x02, 0x01, 0x21, 0xc1, 0x2f, 0xb4, 0x54, 0xab, 0x56, 0x29, 0x6a, 0xe5, 0xac, + 0xf8, 0xd1, 0x3f, 0x96, 0xe3, 0xdc, 0x3a, 0x23, 0x3b, 0xf6, 0xec, 0xcc, 0xb8, 0x8e, 0x9f, 0x83, + 0x37, 0xe0, 0x99, 0x78, 0x20, 0x34, 0x1f, 0x71, 0xec, 0x14, 0x50, 0xf9, 0xb5, 0xbe, 0xc7, 0x77, + 0xce, 0x3d, 0x7b, 0xce, 0x9d, 0x18, 0x2e, 0x05, 0x8d, 0x33, 0xce, 0xa2, 0x99, 0xfa, 0x8b, 0x7c, + 0xca, 0x78, 0x2e, 0x73, 0x32, 0xb0, 0xa8, 0xf7, 0x1c, 0x60, 0x81, 0xd5, 0xcb, 0x3c, 0x0a, 0x65, + 0xce, 0xc9, 0xe7, 0x00, 0x09, 0x56, 0xc1, 0xdb, 0x70, 0x4b, 0xd3, 0xca, 0xed, 0x5c, 0x77, 0x6e, + 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, 0xa7, 0xb1, 0x13, 0xa4, 0x7d, 0xab, 0x0e, 0xb1, 0x37, 0x18, 0x8e, 0x57, 0xe8, + 0x0e, 0xc6, 0xad, 0x20, 0xc9, 0xe3, 0xba, 0xf5, 0x78, 0x79, 0xae, 0xae, 0xfe, 0xed, 0x95, 0x60, + 0xe4, 0x39, 0x9c, 0x3f, 0x43, 0x4e, 0xdf, 0x61, 0x6d, 0x63, 0x83, 0xe9, 0x38, 0xfe, 0x06, 0xd3, + 0x7b, 0xae, 0xdf, 0xce, 0xde, 0x7c, 0x13, 0x53, 0xb9, 0x29, 0x56, 0xd3, 0x28, 0xdf, 0xce, 0x52, + 0x1a, 0x6f, 0x64, 0x46, 0xb3, 0x38, 0x43, 0x59, 0xe6, 0x3c, 0x99, 0xa5, 0xd9, 0x7a, 0x96, 0xd6, + 0x5f, 0x26, 0xce, 0xa2, 0x55, 0x5f, 0x7f, 0x9b, 0xbe, 0xff, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x7d, + 0x28, 0x4a, 0xad, 0xb3, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -882,8 +897,9 @@ type SignerClient interface { // //DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key //derivation between the ephemeral public key in the request and the node's - //key specified in the key_loc parameter (or the node's identity private key - //if no key locator is specified): + //key specified in the key_desc parameter. Either a key locator or a raw + //public key is expected in the key_desc, if neither is supplied, defaults to + //the node's identity private key: //P_shared = privKeyNode * ephemeralPubkey //The resulting shared public key is serialized in the compressed format and //hashed with sha256, resulting in the final key length of 256bit. @@ -984,8 +1000,9 @@ type SignerServer interface { // //DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key //derivation between the ephemeral public key in the request and the node's - //key specified in the key_loc parameter (or the node's identity private key - //if no key locator is specified): + //key specified in the key_desc parameter. Either a key locator or a raw + //public key is expected in the key_desc, if neither is supplied, defaults to + //the node's identity private key: //P_shared = privKeyNode * ephemeralPubkey //The resulting shared public key is serialized in the compressed format and //hashed with sha256, resulting in the final key length of 256bit. diff --git a/lnrpc/signrpc/signer.proto b/lnrpc/signrpc/signer.proto index 003d1e7e..d0afc33b 100644 --- a/lnrpc/signrpc/signer.proto +++ b/lnrpc/signrpc/signer.proto @@ -54,8 +54,9 @@ service Signer { /* DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key derivation between the ephemeral public key in the request and the node's - key specified in the key_loc parameter (or the node's identity private key - if no key locator is specified): + key specified in the key_desc parameter. Either a key locator or a raw + public key is expected in the key_desc, if neither is supplied, defaults to + the node's identity private key: P_shared = privKeyNode * ephemeralPubkey The resulting shared public key is serialized in the compressed format and hashed with sha256, resulting in the final key length of 256bit. @@ -220,10 +221,18 @@ message SharedKeyRequest { bytes ephemeral_pubkey = 1; /* - The optional key locator of the local key that should be used. If this - parameter is not set then the node's identity private key will be used. + Deprecated. The optional key locator of the local key that should be used. + If this parameter is not set then the node's identity private key will be + used. */ - KeyLocator key_loc = 2; + KeyLocator key_loc = 2 [deprecated = true]; + + /* + A key descriptor describes the key used for performing ECDH. Either a key + locator or a raw public key is expected, if neither is supplied, defaults to + the node's identity private key. + */ + KeyDescriptor key_desc = 3; } message SharedKeyResponse { diff --git a/lnrpc/signrpc/signer.swagger.json b/lnrpc/signrpc/signer.swagger.json index 594a9b82..e539204f 100644 --- a/lnrpc/signrpc/signer.swagger.json +++ b/lnrpc/signrpc/signer.swagger.json @@ -47,7 +47,7 @@ }, "/v2/signer/sharedkey": { "post": { - "summary": "DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key\nderivation between the ephemeral public key in the request and the node's\nkey specified in the key_loc parameter (or the node's identity private key\nif no key locator is specified):\nP_shared = privKeyNode * ephemeralPubkey\nThe resulting shared public key is serialized in the compressed format and\nhashed with sha256, resulting in the final key length of 256bit.", + "summary": "DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key\nderivation between the ephemeral public key in the request and the node's\nkey specified in the key_desc parameter. Either a key locator or a raw\npublic key is expected in the key_desc, if neither is supplied, defaults to\nthe node's identity private key:\nP_shared = privKeyNode * ephemeralPubkey\nThe resulting shared public key is serialized in the compressed format and\nhashed with sha256, resulting in the final key length of 256bit.", "operationId": "DeriveSharedKey", "responses": { "200": { @@ -284,7 +284,11 @@ }, "key_loc": { "$ref": "#/definitions/signrpcKeyLocator", - "description": "The optional key locator of the local key that should be used. If this\nparameter is not set then the node's identity private key will be used." + "description": "Deprecated. The optional key locator of the local key that should be used.\nIf this parameter is not set then the node's identity private key will be\nused." + }, + "key_desc": { + "$ref": "#/definitions/signrpcKeyDescriptor", + "description": "A key descriptor describes the key used for performing ECDH. Either a key\nlocator or a raw public key is expected, if neither is supplied, defaults to\nthe node's identity private key." } } }, diff --git a/lnrpc/signrpc/signer_server.go b/lnrpc/signrpc/signer_server.go index a723c391..41faba58 100644 --- a/lnrpc/signrpc/signer_server.go +++ b/lnrpc/signrpc/signer_server.go @@ -254,27 +254,11 @@ func (s *Server) SignOutputRaw(ctx context.Context, in *SignReq) (*SignResp, err // If this method doesn't return nil, then we know that user is // attempting to include a raw serialized pub key. if keyDesc.GetRawKeyBytes() != nil { - rawKeyBytes := keyDesc.GetRawKeyBytes() - - switch { - // If the user provided a raw key, but it's of the - // wrong length, then we'll return with an error. - case len(rawKeyBytes) != 0 && len(rawKeyBytes) != 33: - - return nil, fmt.Errorf("pubkey must be " + - "serialized in compressed format if " + - "specified") - - // If a proper raw key was provided, then we'll attempt - // to decode and parse it. - case len(rawKeyBytes) != 0 && len(rawKeyBytes) == 33: - targetPubKey, err = btcec.ParsePubKey( - rawKeyBytes, btcec.S256(), - ) - if err != nil { - return nil, fmt.Errorf("unable to "+ - "parse pubkey: %v", err) - } + targetPubKey, err = parseRawKeyBytes( + keyDesc.GetRawKeyBytes(), + ) + if err != nil { + return nil, err } } @@ -507,38 +491,82 @@ func (s *Server) VerifyMessage(ctx context.Context, // DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key // derivation between the ephemeral public key in the request and the node's -// key specified in the key_loc parameter (or the node's identity private key -// if no key locator is specified): -// P_shared = privKeyNode * ephemeralPubkey +// key specified in the key_desc parameter. Either a key locator or a raw public +// key is expected in the key_desc, if neither is supplied, defaults to the +// node's identity private key. The old key_loc parameter in the request +// shouldn't be used anymore. // The resulting shared public key is serialized in the compressed format and // hashed with sha256, resulting in the final key length of 256bit. func (s *Server) DeriveSharedKey(_ context.Context, in *SharedKeyRequest) ( *SharedKeyResponse, error) { - if len(in.EphemeralPubkey) != 33 { - return nil, fmt.Errorf("ephemeral pubkey must be " + - "serialized in compressed format") - } - ephemeralPubkey, err := btcec.ParsePubKey( - in.EphemeralPubkey, btcec.S256(), - ) + // Check that EphemeralPubkey is valid. + ephemeralPubkey, err := parseRawKeyBytes(in.EphemeralPubkey) if err != nil { - return nil, fmt.Errorf("unable to parse pubkey: %v", err) + return nil, fmt.Errorf("error in ephemeral pubkey: %v", err) + } + if ephemeralPubkey == nil { + return nil, fmt.Errorf("must provide ephemeral pubkey") } - // By default, use the node identity private key. - locator := keychain.KeyLocator{ - Family: keychain.KeyFamilyNodeKey, - Index: 0, + // Check for backward compatibility. The caller either specifies the old + // key_loc field, or the new key_desc field, but not both. + if in.KeyDesc != nil && in.KeyLoc != nil { + return nil, fmt.Errorf("use either key_desc or key_loc") } - if in.KeyLoc != nil { - locator.Family = keychain.KeyFamily(in.KeyLoc.KeyFamily) - locator.Index = uint32(in.KeyLoc.KeyIndex) + + // When key_desc is used, the key_desc.key_loc is expected as the caller + // needs to specify the KeyFamily. + if in.KeyDesc != nil && in.KeyDesc.KeyLoc == nil { + return nil, fmt.Errorf("when setting key_desc the field " + + "key_desc.key_loc must also be set") + } + + // We extract two params, rawKeyBytes and keyLoc. Notice their initial + // values will be overwritten if not using the deprecated RPC param. + var rawKeyBytes []byte + keyLoc := in.KeyLoc + if in.KeyDesc != nil { + keyLoc = in.KeyDesc.GetKeyLoc() + rawKeyBytes = in.KeyDesc.GetRawKeyBytes() + } + + // When no keyLoc is supplied, defaults to the node's identity private + // key. + if keyLoc == nil { + keyLoc = &KeyLocator{ + KeyFamily: int32(keychain.KeyFamilyNodeKey), + KeyIndex: 0, + } + } + + // Check the caller is using either the key index or the raw public key + // to perform the ECDH, we can't have both. + if rawKeyBytes != nil && keyLoc.KeyIndex != 0 { + return nil, fmt.Errorf("use either raw_key_bytes or key_index") + } + + // Check the raw public key is valid. Notice that if the rawKeyBytes is + // empty, the parseRawKeyBytes won't return an error, a nil + // *btcec.PublicKey is returned instead. + pk, err := parseRawKeyBytes(rawKeyBytes) + if err != nil { + return nil, fmt.Errorf("error in raw pubkey: %v", err) + } + + // Create a key descriptor. When the KeyIndex is not specified, it uses + // the empty value 0, and when the raw public key is not specified, the + // pk is nil. + keyDescriptor := keychain.KeyDescriptor{ + KeyLocator: keychain.KeyLocator{ + Family: keychain.KeyFamily(keyLoc.KeyFamily), + Index: uint32(keyLoc.KeyIndex), + }, + PubKey: pk, } // Derive the shared key using ECDH and hashing the serialized // compressed shared point. - keyDescriptor := keychain.KeyDescriptor{KeyLocator: locator} sharedKeyHash, err := s.cfg.KeyRing.ECDH(keyDescriptor, ephemeralPubkey) if err != nil { err := fmt.Errorf("unable to derive shared key: %v", err) @@ -548,3 +576,29 @@ func (s *Server) DeriveSharedKey(_ context.Context, in *SharedKeyRequest) ( return &SharedKeyResponse{SharedKey: sharedKeyHash[:]}, nil } + +// parseRawKeyBytes checks that the provided raw public key is valid and returns +// the public key. A nil public key is returned if the length of the rawKeyBytes +// is zero. +func parseRawKeyBytes(rawKeyBytes []byte) (*btcec.PublicKey, error) { + switch { + + case len(rawKeyBytes) == 33: + // If a proper raw key was provided, then we'll attempt + // to decode and parse it. + return btcec.ParsePubKey( + rawKeyBytes, btcec.S256(), + ) + + case len(rawKeyBytes) == 0: + // No key is provided, return nil. + return nil, nil + + default: + // If the user provided a raw key, but it's of the + // wrong length, then we'll return with an error. + return nil, fmt.Errorf("pubkey must be " + + "serialized in compressed format if " + + "specified") + } +}