Daniel Liu
9cad0a0cc0
all: create global hasher pool #31769 ( #1233 )
...
This PR creates a global hasher pool that can be used by all packages.
It also removes a bunch of the package local pools.
It also updates a few locations to use available hashers or the global
hashing pool to reduce allocations all over the codebase.
This change should reduce global allocation count by ~1%
---------
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-08-20 15:11:09 +08:00
Daniel Liu
6b31dedf03
crypto/bn256/gnark: align marshaling behavior #32065 ( #1231 )
...
Aligns the marshaling behavior of gnark to google and cloudflare
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
2025-08-20 15:09:36 +08:00
Daniel Liu
9f360824a9
crypto/bn256: add documentation on subgroup checks for G2 #32066 ( #1232 )
...
This PR improves the IsOnCurve methods for BN254 G2 points by:
* Clarifying its behavior the docstring, making it explicit that it
verifies both the point being on the curve and in the correct subgroup.
* Adding an in-line comment explaining the subgroup membership check
(c.Mul(Order)).
* Minor wording adjustments for readability and consistency.
Co-authored-by: Antonio Sanso <antonio.sanso@gmail.com>
2025-07-26 17:41:09 +08:00
Daniel Liu
f5ad8091e2
crypto/bn256/cloudflare: pull in upstream fix for R27 and R29 usage #32057 ( #1229 )
...
Pulls in https://github.com/cloudflare/bn256/pull/48 to remove usage of
R27 and R29 [which are reserved](https://go.dev/doc/asm#arm64 ).
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
2025-07-26 17:39:28 +08:00
Daniel Liu
0fd51f13a1
tests/fuzzers: added bn marshaling fuzzers #32053 ( #1228 )
...
Adds marshaling fuzzing for G1 and G2 to oss-fuzz.
Also aligns the behavior of the google library to that of gnark and
cloudflare, which only ever read the first 64 / 128 bytes of the input,
regardless of how long the input is
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2025-07-26 17:36:58 +08:00
Daniel Liu
f30a126380
crypto/bn256: fix gnark deserialisation #32055 ( #1227 )
...
fixes the gnark deserialisation
---------
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-07-26 17:35:13 +08:00
Daniel Liu
d06f219dc3
crypto: use pure Go signature implementation in tinygo #31878 ( #1226 )
...
tinygo is having problems compiling the C implementation
Co-authored-by: Ömer Faruk Irmak <omerfirmak@gmail.com>
2025-07-26 17:33:55 +08:00
Daniel Liu
badb46ce2b
crypto: remove kgz4844 ( #1225 )
2025-07-26 17:32:07 +08:00
Marius van der Wijden
5bf4da1f47
crypto/secp256k1: update libsecp256k1 ( #31242 )
...
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)
```
2025-03-19 18:02:46 +08:00
Marius van der Wijden
31cc9b0d5f
crypto: add comment to FromECDSAPub ( #31241 )
...
closes https://github.com/ethereum/go-ethereum/issues/26240
2025-03-19 18:02:46 +08:00
Daniel Liu
6ec0d13873
core/txpool, crypto, node: fix os.CreateTemp in test ( #31172 )
2025-03-19 18:02:46 +08:00
Ryan Tinianov
76a5008ec7
all: add build tags for wasip1 ( #31090 )
2025-03-19 18:02:46 +08:00
Felix Lange
98ad241607
crypto: add IsOnCurve check ( #31100 )
2025-03-19 18:02:46 +08:00
Daniel Liu
f7c46d0ad7
crypto: fix some typos in comments and names ( #31023 )
2025-03-19 18:02:46 +08:00
Daniel Liu
77ad10c890
crypto/kz4844: pass blobs by ref ( #29050 )
2025-02-11 18:26:56 +08:00
Daniel Liu
ed67fd4200
crypto/secp256k1: remove external LGPL dependencies ( #17239 )
2025-01-24 16:18:28 +08:00
gitglorythegreat
9ca3d10001
crypto/bn256: fix MulScalar ( #30974 )
...
The `a` parameter should be used in the `MulScalar` function. The
upstream cloudflare and google repos have already merged fixes.
Reference:
*
8d7daa0c54
* https://github.com/cloudflare/bn256/pull/33
2025-01-04 11:00:57 +08:00
kevaundray
e581093ce1
crypto, tests/fuzzers: add gnark bn254 precompile methods for fuzzing ( #30585 )
...
Makes the gnark precompile methods more amenable to fuzzing
2025-01-04 11:00:57 +08:00
Daniel Liu
15be5ba464
crypto: use decred secp256k1 directly ( #30595 )
2025-01-04 11:00:57 +08:00
zhiqiangxu
e19093f344
crypto: remove hardcoded value for secp256k1.N ( #30126 )
2025-01-04 11:00:57 +08:00
SuiYuan
104a97354a
crypto/secp256k1: change receiver variable name to lowercase ( #29889 )
2025-01-04 11:00:57 +08:00
George Ma
136e87fa4c
crypto: fix docstrings and comments
2025-01-04 11:00:57 +08:00
Daniel Liu
efad15f9f4
crypto: use clear from go1.21 ( #29307 )
2025-01-04 11:00:57 +08:00
Daniel Liu
d0566e4165
crypto: update to go version 1.22 ( #28946 )
2025-01-04 11:00:57 +08:00
Daniel Liu
3fbbc9da9f
crypto: fix typos in comments ( #29186 )
2024-12-09 17:49:00 +08:00
Daniel Liu
727855752c
crypto: add support for blobs in eth_fillTransaction ( #28839 )
2024-12-09 17:49:00 +08:00
Daniel Liu
fabfcc7f6c
crypto: fix docstring names ( #28923 )
2024-12-09 17:49:00 +08:00
Daniel Liu
cae53aa7fd
crypto/kzg4844: add helpers for versioned blob hashes ( #28827 )
2024-12-09 17:49:00 +08:00
Daniel Liu
824dea669c
crypto/kzg4844: use the new trusted setup file and format ( #28383 )
2024-12-09 17:49:00 +08:00
Daniel Liu
b5cc7e6fc0
crypto/blake2b: put architecture-dependent features behind build-tag ( #28381 )
...
This change to fixes a compilation-flaw on master, by putting architecture-specific functions behind corresponding build tags.
2024-12-09 17:49:00 +08:00
Daniel Liu
f7b6ad67a7
crypto, tests: update fuzzers to native go fuzzing ( #28352 )
2024-12-09 17:49:00 +08:00
Daniel Liu
247ebd6a6d
crypto/kzg4844: do lazy init in all ckzg funcs ( #27679 )
...
* crypto/kzg4844: remove unnecessary init call & fix typo
* Fix kzg4844 tests/benchmarks
* Make init lazy & revert changes to tests
2024-12-09 17:49:00 +08:00
Daniel Liu
bd93c59bae
crypto: replace noarg fmt.Errorf with errors.New ( #27333 )
2024-12-09 17:49:00 +08:00
Daniel Liu
ed03a99770
crypto/kzg4844: upgrade c-kzg-4844 to v0.2.0 ( #27257 )
2024-12-09 17:49:00 +08:00
Daniel Liu
bedd571091
crypto/kzg4844: pull in the C and Go libs for KZG cryptography ( #27155 )
2024-12-09 17:49:00 +08:00
Daniel Liu
797efe74af
crypto: more linters and fix typo ( #24783 )
2024-12-09 17:49:00 +08:00
Daniel Liu
cb3edac2c7
crypto: use btcec/v2 for no-cgo ( #24533 )
2024-12-09 17:49:00 +08:00
Daniel Liu
949fa6358e
crypto/ecies: use AES-192 for curve P384 ( #24139 )
...
Using curve P384 for encryption causes the error "ecies: shared key params
are too big". Also, readme.md says curve P384 should use AES192 not AES256.
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2024-12-09 17:49:00 +08:00
Daniel Liu
146bc2be7b
crypto: add go:build lines ( #23468 )
2024-12-09 17:49:00 +08:00
Daniel Liu
9dab065373
crypto: gofuzz build directives ( #23137 )
2024-12-09 17:49:00 +08:00
Daniel Liu
b1c719029c
crypto: improve trie updates ( #21047 )
2024-12-09 17:49:00 +08:00
Daniel Liu
a64e42463a
crypto/bn256: refine comments according to #19577 , #21595 , and #21836 ( #21847 )
2024-12-09 17:49:00 +08:00
Daniel Liu
a2eb8553e8
crypto/bn256: better comments for u, P and Order ( #21836 )
2024-12-09 17:49:00 +08:00
Daniel Liu
f948466976
crypto: less allocations when hashing and tx handling ( #21265 )
2024-12-09 17:49:00 +08:00
Daniel Liu
ee303c9f3d
crypto/ecies: improve concatKDF ( #20836 )
2024-12-09 17:48:59 +08:00
Daniel Liu
b2be754647
crypto/bn256: fix import line ( #20723 )
2024-12-09 17:48:59 +08:00
Daniel Liu
6033722b72
crypto: use golangci-lint ( #20295 )
2024-12-09 17:48:59 +08:00
Daniel Liu
e1eb00ef99
crypto: make unit tests work with Go 1.13 ( #20053 )
2024-12-09 17:48:59 +08:00
Daniel Liu
ad5e7d6db3
crypto: add SignatureLength constant and use it everywhere ( #19996 )
2024-12-09 17:48:59 +08:00
Daniel Liu
8dcea8ddf8
crypto: replace t.Log(); t.FailNow() with t.Fatal() ( #19849 )
2024-12-09 17:48:59 +08:00