mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 00:39:26 +00:00
Updates the libsecp256k1 dependency to commit: c0d9480fbbf8eccbd4be23ed27f6f2af6f3b211e PR: ``` BenchmarkSign-24 57756 21214 ns/op 164 B/op 3 allocs/op BenchmarkRecover-24 37156 33044 ns/op 80 B/op 1 allocs/op BenchmarkEcrecoverSignature-24 36889 32935 ns/op 80 B/op 1 allocs/op BenchmarkVerifySignature-24 41163 29207 ns/op 0 B/op 0 allocs/op BenchmarkDecompressPubkey-24 318624 4062 ns/op 304 B/op 6 allocs/op ``` Master: ``` BenchmarkSign-24 34509 35330 ns/op 164 B/op 3 allocs/op BenchmarkRecover-24 25418 47725 ns/op 80 B/op 1 allocs/op BenchmarkEcrecoverSignature-24 25735 47591 ns/op 80 B/op 1 allocs/op BenchmarkVerifySignature-24 29108 41097 ns/op 0 B/op 0 allocs/op BenchmarkDecompressPubkey-24 294747 4143 ns/op 304 B/op 6 allocs/op ``` Performance seems to be improved significantly: ``` Sign-24 34.86µ ± 3% 21.66µ ± 2% -37.86% (p=0.000 n=10) Recover-24 46.14µ ± 3% 33.24µ ± 2% -27.95% (p=0.000 n=10) ```
32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
/***********************************************************************
|
|
* Copyright (c) 2020 Pieter Wuille *
|
|
* Distributed under the MIT software license, see the accompanying *
|
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
***********************************************************************/
|
|
|
|
#ifndef SECP256K1_SELFTEST_H
|
|
#define SECP256K1_SELFTEST_H
|
|
|
|
#include "hash.h"
|
|
|
|
#include <string.h>
|
|
|
|
static int secp256k1_selftest_sha256(void) {
|
|
static const char *input63 = "For this sample, this 63-byte string will be used as input data";
|
|
static const unsigned char output32[32] = {
|
|
0xf0, 0x8a, 0x78, 0xcb, 0xba, 0xee, 0x08, 0x2b, 0x05, 0x2a, 0xe0, 0x70, 0x8f, 0x32, 0xfa, 0x1e,
|
|
0x50, 0xc5, 0xc4, 0x21, 0xaa, 0x77, 0x2b, 0xa5, 0xdb, 0xb4, 0x06, 0xa2, 0xea, 0x6b, 0xe3, 0x42,
|
|
};
|
|
unsigned char out[32];
|
|
secp256k1_sha256 hasher;
|
|
secp256k1_sha256_initialize(&hasher);
|
|
secp256k1_sha256_write(&hasher, (const unsigned char*)input63, 63);
|
|
secp256k1_sha256_finalize(&hasher, out);
|
|
return secp256k1_memcmp_var(out, output32, 32) == 0;
|
|
}
|
|
|
|
static int secp256k1_selftest_passes(void) {
|
|
return secp256k1_selftest_sha256();
|
|
}
|
|
|
|
#endif /* SECP256K1_SELFTEST_H */
|