accounts, eth, clique, signer: support for external signer API (#18079)
* accounts, eth, clique: implement external backend + move sighash calc to backend * signer: implement account_Version on external API * accounts/external: enable ipc, add copyright * accounts, internal, signer: formatting * node: go fmt * flags: disallow --dev in combo with --externalsigner * accounts: remove clique-specific signing method, replace with more generic * accounts, consensus: formatting + fix error in tests * signer/core: remove (test-) import cycle * clique: remove unused import * accounts: remove CliqueHash and avoid dependency on package crypto * consensus/clique: unduplicate header encoding
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							520024dfd6
						
					
				
				
					commit
					43e8efe895
				
			| @@ -217,7 +217,7 @@ func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ListAccounts will return a list of addresses for accounts this node manages. | ||||
| // listAccounts will return a list of addresses for accounts this node manages. | ||||
| func (s *PrivateAccountAPI) ListAccounts() []common.Address { | ||||
| 	addresses := make([]common.Address, 0) // return [] instead of nil if empty | ||||
| 	for _, wallet := range s.am.Wallets() { | ||||
| @@ -409,18 +409,6 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs | ||||
| 	return &SignTransactionResult{data, signed}, nil | ||||
| } | ||||
|  | ||||
| // signHash is a helper function that calculates a hash for the given message that can be | ||||
| // safely used to calculate a signature from. | ||||
| // | ||||
| // The hash is calulcated as | ||||
| //   keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). | ||||
| // | ||||
| // This gives context to the signed message and prevents signing of transactions. | ||||
| func signHash(data []byte) []byte { | ||||
| 	msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data) | ||||
| 	return crypto.Keccak256([]byte(msg)) | ||||
| } | ||||
|  | ||||
| // Sign calculates an Ethereum ECDSA signature for: | ||||
| // keccack256("\x19Ethereum Signed Message:\n" + len(message) + message)) | ||||
| // | ||||
| @@ -439,7 +427,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	// Assemble sign the data with the wallet | ||||
| 	signature, err := wallet.SignHashWithPassphrase(account, passwd, signHash(data)) | ||||
| 	signature, err := wallet.SignTextWithPassphrase(account, passwd, data) | ||||
| 	if err != nil { | ||||
| 		log.Warn("Failed data sign attempt", "address", addr, "err", err) | ||||
| 		return nil, err | ||||
| @@ -467,7 +455,7 @@ func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Byt | ||||
| 	} | ||||
| 	sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1 | ||||
|  | ||||
| 	rpk, err := crypto.SigToPub(signHash(data), sig) | ||||
| 	rpk, err := crypto.SigToPub(accounts.TextHash(data), sig) | ||||
| 	if err != nil { | ||||
| 		return common.Address{}, err | ||||
| 	} | ||||
| @@ -1357,7 +1345,7 @@ func (s *PublicTransactionPoolAPI) Sign(addr common.Address, data hexutil.Bytes) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	// Sign the requested hash with the wallet | ||||
| 	signature, err := wallet.SignHash(account, signHash(data)) | ||||
| 	signature, err := wallet.SignText(account, data) | ||||
| 	if err == nil { | ||||
| 		signature[64] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user