Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0c5f8c07
Unverified
Commit
0c5f8c07
authored
May 15, 2019
by
Martin Holst Swende
Committed by
GitHub
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts,signer: better support for EIP-191 intended validator (#19523)
parent
b548b5ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
accounts.go
accounts/accounts.go
+1
-1
signed_data.go
signer/core/signed_data.go
+21
-7
No files found.
accounts/accounts.go
View file @
0c5f8c07
...
@@ -36,7 +36,7 @@ type Account struct {
...
@@ -36,7 +36,7 @@ type Account struct {
}
}
const
(
const
(
Mimetype
TextWithValidator
=
"text
/validator"
Mimetype
DataWithValidator
=
"data
/validator"
MimetypeTypedData
=
"data/typed"
MimetypeTypedData
=
"data/typed"
MimetypeClique
=
"application/x-clique-header"
MimetypeClique
=
"application/x-clique-header"
MimetypeTextPlain
=
"text/plain"
MimetypeTextPlain
=
"text/plain"
...
...
signer/core/signed_data.go
View file @
0c5f8c07
...
@@ -46,8 +46,8 @@ type SigFormat struct {
...
@@ -46,8 +46,8 @@ type SigFormat struct {
}
}
var
(
var
(
Text
Validator
=
SigFormat
{
Intended
Validator
=
SigFormat
{
accounts
.
Mimetype
Text
WithValidator
,
accounts
.
Mimetype
Data
WithValidator
,
0x00
,
0x00
,
}
}
DataTyped
=
SigFormat
{
DataTyped
=
SigFormat
{
...
@@ -191,7 +191,7 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
...
@@ -191,7 +191,7 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
}
}
switch
mediaType
{
switch
mediaType
{
case
Text
Validator
.
Mime
:
case
Intended
Validator
.
Mime
:
// Data with an intended validator
// Data with an intended validator
validatorData
,
err
:=
UnmarshalValidatorData
(
data
)
validatorData
,
err
:=
UnmarshalValidatorData
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -200,9 +200,24 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
...
@@ -200,9 +200,24 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
sighash
,
msg
:=
SignTextValidator
(
validatorData
)
sighash
,
msg
:=
SignTextValidator
(
validatorData
)
message
:=
[]
*
NameValueType
{
message
:=
[]
*
NameValueType
{
{
{
Name
:
"message"
,
Name
:
"This is a request to sign data intended for a particular validator (see EIP 191 version 0)"
,
Typ
:
"text"
,
Typ
:
"description"
,
Value
:
msg
,
Value
:
""
,
},
{
Name
:
"Intended validator address"
,
Typ
:
"address"
,
Value
:
validatorData
.
Address
.
String
(),
},
{
Name
:
"Application-specific data"
,
Typ
:
"hexdata"
,
Value
:
validatorData
.
Message
,
},
{
Name
:
"Full message for signing"
,
Typ
:
"hexdata"
,
Value
:
fmt
.
Sprintf
(
"0x%x"
,
msg
),
},
},
}
}
req
=
&
SignDataRequest
{
ContentType
:
mediaType
,
Rawdata
:
[]
byte
(
msg
),
Message
:
message
,
Hash
:
sighash
}
req
=
&
SignDataRequest
{
ContentType
:
mediaType
,
Rawdata
:
[]
byte
(
msg
),
Message
:
message
,
Hash
:
sighash
}
...
@@ -275,7 +290,6 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
...
@@ -275,7 +290,6 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
// hash = keccak256("\x19\x00"${address}${data}).
// hash = keccak256("\x19\x00"${address}${data}).
func
SignTextValidator
(
validatorData
ValidatorData
)
(
hexutil
.
Bytes
,
string
)
{
func
SignTextValidator
(
validatorData
ValidatorData
)
(
hexutil
.
Bytes
,
string
)
{
msg
:=
fmt
.
Sprintf
(
"
\x19\x00
%s%s"
,
string
(
validatorData
.
Address
.
Bytes
()),
string
(
validatorData
.
Message
))
msg
:=
fmt
.
Sprintf
(
"
\x19\x00
%s%s"
,
string
(
validatorData
.
Address
.
Bytes
()),
string
(
validatorData
.
Message
))
fmt
.
Printf
(
"SignTextValidator:%s
\n
"
,
msg
)
return
crypto
.
Keccak256
([]
byte
(
msg
)),
msg
return
crypto
.
Keccak256
([]
byte
(
msg
)),
msg
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment