def sign(self, privkey):
if self.v:<EOL><INDENT>raise InvalidSignature("<STR_LIT>")<EOL><DEDENT>if privkey in (<NUM_LIT:0>, '<STR_LIT>', '<STR_LIT:\x00>' * <NUM_LIT:32>):<EOL><INDENT>raise InvalidSignature("<STR_LIT>")<EOL><DEDENT>rawhash = sha3(rlp.encode(self, self.__class__.exclude(['<STR_LIT:v>', '<STR_LIT:r>', '<STR_LIT:s>'])))<EOL>if len(privkey) == <NUM_LIT:64>:<EOL><INDENT>privkey = encode_privkey(privkey, '<STR_LIT>')<EOL><DEDENT>pk = PrivateKey(privkey, raw=True)<EOL>signature = pk.ecdsa_recoverable_serialize(pk.ecdsa_sign_recoverable(rawhash, raw=True))<EOL>signature = signature[<NUM_LIT:0>] + chr(signature[<NUM_LIT:1>])<EOL>self.v = ord(signature[<NUM_LIT:64>]) + <NUM_LIT><EOL>self.r = big_endian_to_int(signature[<NUM_LIT:0>:<NUM_LIT:32>])<EOL>self.s = big_endian_to_int(signature[<NUM_LIT:32>:<NUM_LIT:64>])<EOL>self._sender = None<EOL>return self<EOL>
Sign this with a private key