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
92c34714
Commit
92c34714
authored
Jan 05, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secp256k1 method signing
parent
53a30740
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
transaction.go
transaction.go
+23
-0
No files found.
transaction.go
View file @
92c34714
...
...
@@ -3,6 +3,7 @@ package main
import
(
"math/big"
"fmt"
"github.com/obscuren/secp256k1-go"
_
"encoding/hex"
_
"crypto/sha256"
_
"bytes"
...
...
@@ -73,6 +74,28 @@ func (tx *Transaction) Hash() []byte {
return
Sha256Bin
(
tx
.
MarshalRlp
())
}
func
(
tx
*
Transaction
)
IsContract
()
bool
{
return
tx
.
recipient
==
""
}
func
(
tx
*
Transaction
)
Signature
()
[]
byte
{
hash
:=
Sha256Bin
(
tx
.
MarshalRlp
())
sec
:=
Sha256Bin
([]
byte
(
"myprivkey"
))
sig
,
_
:=
secp256k1
.
Sign
(
hash
,
sec
)
return
sig
}
func
(
tx
*
Transaction
)
PublicKey
()
[]
byte
{
hash
:=
Sha256Bin
(
tx
.
MarshalRlp
())
sig
:=
tx
.
Signature
()
pubkey
,
_
:=
secp256k1
.
RecoverPubkey
(
hash
,
sig
)
return
pubkey
}
func
(
tx
*
Transaction
)
MarshalRlp
()
[]
byte
{
// Prepare the transaction for serialization
preEnc
:=
[]
interface
{}{
...
...
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