mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
Added ecRecover method in the clef api
This commit is contained in:
parent
8b5d1d163e
commit
6076456d91
2 changed files with 5 additions and 8 deletions
|
|
@ -50,11 +50,9 @@ type ExternalAPI interface {
|
||||||
// SignTransaction request to sign the specified transaction
|
// SignTransaction request to sign the specified transaction
|
||||||
SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error)
|
SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error)
|
||||||
// SignData - request to sign the given data (plus prefix)
|
// SignData - request to sign the given data (plus prefix)
|
||||||
SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data interface{}) (hexutil.Bytes, error)
|
SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data hexutil.Bytes) (hexutil.Bytes, error)
|
||||||
// SignTypedData - request to sign the given structured data (plus prefix)
|
|
||||||
SignTypedData(ctx context.Context, addr common.MixedcaseAddress, data TypedData) (hexutil.Bytes, error)
|
|
||||||
// EcRecover - recover public key from given message and signature
|
// EcRecover - recover public key from given message and signature
|
||||||
EcRecover(ctx context.Context, data hexutil.Bytes, sig hexutil.Bytes) (common.Address, error)
|
EcRecover(ctx context.Context, contentType string, data hexutil.Bytes, sig hexutil.Bytes) (common.Address, error)
|
||||||
// Export - request to export an account
|
// Export - request to export an account
|
||||||
Export(ctx context.Context, addr common.Address) (json.RawMessage, error)
|
Export(ctx context.Context, addr common.Address) (json.RawMessage, error)
|
||||||
// Import - request to import an account
|
// Import - request to import an account
|
||||||
|
|
@ -697,7 +695,6 @@ func SignDataPlain(data []byte) ([]byte, string) {
|
||||||
|
|
||||||
// Determines the content type and then recovers the address associated with the given sig
|
// Determines the content type and then recovers the address associated with the given sig
|
||||||
func (api *SignerAPI) EcRecover(ctx context.Context, contentType string, data, sig hexutil.Bytes) (common.Address, error) {
|
func (api *SignerAPI) EcRecover(ctx context.Context, contentType string, data, sig hexutil.Bytes) (common.Address, error) {
|
||||||
fmt.Println("Effing Muffins")
|
|
||||||
mediaType, _, err := mime.ParseMediaType(contentType)
|
mediaType, _, err := mime.ParseMediaType(contentType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, err
|
return common.Address{}, err
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,10 @@ func (l *AuditLogger) SignTypedData(ctx context.Context, addr common.MixedcaseAd
|
||||||
return b, e
|
return b, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *AuditLogger) EcRecover(ctx context.Context, data hexutil.Bytes, sig hexutil.Bytes) (common.Address, error) {
|
func (l *AuditLogger) EcRecover(ctx context.Context, contentType string, data hexutil.Bytes, sig hexutil.Bytes) (common.Address, error) {
|
||||||
l.log.Info("EcRecover", "type", "request", "metadata", MetadataFromContext(ctx).String(),
|
l.log.Info("EcRecover", "type", "request", "metadata", MetadataFromContext(ctx).String(),
|
||||||
"data", common.Bytes2Hex(data), "sig", common.Bytes2Hex(sig))
|
"data", common.Bytes2Hex(data), "sig", common.Bytes2Hex(sig), "content-type", contentType)
|
||||||
b, e := l.api.EcRecover(ctx, data, sig)
|
b, e := l.api.EcRecover(ctx, contentType, data, sig)
|
||||||
l.log.Info("EcRecover", "type", "response", "address", b.String(), "error", e)
|
l.log.Info("EcRecover", "type", "response", "address", b.String(), "error", e)
|
||||||
return b, e
|
return b, e
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue