good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
27a50c8f
Commit
27a50c8f
authored
9 years ago
by
Gustav Simonsson
Browse files
Options
Downloads
Patches
Plain Diff
core/secp256k1: update libsecp256k1 Go wrapper and tests
parent
66d47ced
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
crypto/secp256k1/secp256.go
+2
-2
2 additions, 2 deletions
crypto/secp256k1/secp256.go
crypto/secp256k1/secp256_test.go
+15
-16
15 additions, 16 deletions
crypto/secp256k1/secp256_test.go
with
17 additions
and
18 deletions
crypto/secp256k1/secp256.go
+
2
−
2
View file @
27a50c8f
...
...
@@ -96,7 +96,7 @@ func GenerateKeyPair() ([]byte, []byte) {
var
output_len
C
.
size_t
C
.
secp256k1_ec_pubkey_serialize
(
// always returns 1
_
=
C
.
secp256k1_ec_pubkey_serialize
(
// always returns 1
context
,
pubkey65_ptr
,
&
output_len
,
...
...
@@ -163,7 +163,7 @@ func Sign(msg []byte, seckey []byte) ([]byte, error) {
sig_serialized_ptr
:=
(
*
C
.
uchar
)(
unsafe
.
Pointer
(
&
sig_serialized
[
0
]))
var
recid
C
.
int
C
.
secp256k1_ecdsa_recoverable_signature_serialize_compact
(
_
=
C
.
secp256k1_ecdsa_recoverable_signature_serialize_compact
(
context
,
sig_serialized_ptr
,
// 64 byte compact signature
&
recid
,
...
...
This diff is collapsed.
Click to expand it.
crypto/secp256k1/secp256_test.go
+
15
−
16
View file @
27a50c8f
...
...
@@ -86,10 +86,7 @@ func TestSignAndRecover(t *testing.T) {
func
TestRandomMessagesWithSameKey
(
t
*
testing
.
T
)
{
pubkey
,
seckey
:=
GenerateKeyPair
()
keys
:=
func
()
([]
byte
,
[]
byte
)
{
// Sign function zeroes the privkey so we need a new one in each call
newkey
:=
make
([]
byte
,
len
(
seckey
))
copy
(
newkey
,
seckey
)
return
pubkey
,
newkey
return
pubkey
,
seckey
}
signAndRecoverWithRandomMessages
(
t
,
keys
)
}
...
...
@@ -209,30 +206,32 @@ func compactSigCheck(t *testing.T, sig []byte) {
}
}
// godep go test -v -run=XXX -bench=BenchmarkSign
RandomInputEachRound
// godep go test -v -run=XXX -bench=BenchmarkSign
// add -benchtime=10s to benchmark longer for more accurate average
func
BenchmarkSignRandomInputEachRound
(
b
*
testing
.
B
)
{
// to avoid compiler optimizing the benchmarked function call
var
err
error
func
BenchmarkSign
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
b
.
StopTimer
()
_
,
seckey
:=
GenerateKeyPair
()
msg
:=
randentropy
.
GetEntropyCSPRNG
(
32
)
b
.
StartTimer
()
if
_
,
e
rr
:=
Sign
(
msg
,
seckey
)
;
err
!=
nil
{
b
.
Fatal
(
err
)
}
_
,
e
:=
Sign
(
msg
,
seckey
)
err
=
e
b
.
StopTimer
()
}
}
//godep go test -v -run=XXX -bench=BenchmarkRec
overRandomInputEachRound
func
BenchmarkRecover
RandomInputEachRound
(
b
*
testing
.
B
)
{
//godep go test -v -run=XXX -bench=Benchmark
EC
Rec
func
BenchmarkRecover
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
b
.
StopTimer
()
_
,
seckey
:=
GenerateKeyPair
()
msg
:=
randentropy
.
GetEntropyCSPRNG
(
32
)
sig
,
_
:=
Sign
(
msg
,
seckey
)
b
.
StartTimer
()
if
_
,
e
rr
:=
RecoverPubkey
(
msg
,
sig
)
;
err
!=
nil
{
b
.
Fatal
(
err
)
}
_
,
e
:=
RecoverPubkey
(
msg
,
sig
)
err
=
e
b
.
StopTimer
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment