Commit graph

316 commits

Author SHA1 Message Date
Lessa
2513feddf8
crypto/kzg4844: preallocate proof slice in ComputeCellProofs (#33703)
Preallocate the proof slice with the known size instead of growing it
via append in a loop. The length is already known from the source slice.
2026-01-29 15:49:10 +08:00
lightclient
3b17e78274 crypto/ecies: use aes blocksize
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2026-01-13 17:12:23 +01:00
David Klank
a9eaf2ffd8
crypto/signify: fix fuzz test compilation (#33402)
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Keeper Build (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
The fuzz test file has been broken for a while - it doesn't compile with
the `gofuzz` build tag.

Two issues:
- Line 59: called `SignifySignFile` which doesn't exist (should be
`SignFile`)
- Line 71: used `:=` instead of `=` for already declared `err` variable
2025-12-13 12:09:07 +08:00
Lucia
ebc7dc9e37
crypto: validate hash length in no cgo Sign (#33104)
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Keeper Build (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
- Replace hardcoded DigestLength 
- Add hash length validation
2025-11-08 11:25:53 +01:00
Guillaume Ballet
f1be21501f
crypto: implement ziren keccak state (#32996)
The #32816 was only using the keccak precompile for some minor task.
This PR implements a keccak state, which is what is used for hashing the
tree.
2025-10-23 14:02:13 +02:00
Guillaume Ballet
b1809d13d1
cmd/keeper: use the ziren keccak precompile (#32816)
Uses the go module's `replace` directive to delegate keccak computation
to precompiles.

This is still in draft because it needs more testing. Also, it relies on
a PR that I created, that hasn't been merged yet.

_Note that this PR doesn't implement the stateful keccak state
structure, and it reverts to the current behavior. This is a bit silly
since this is what is used in the tree root computation. The runtime
doesn't currently export the sponge. I will see if I can fix that in a
further PR, but it is going to take more time. In the meantime, this is
a useful first step_
2025-10-20 11:52:02 +02:00
rjl493456442
8dfd30fdd1
core/txpool/blobpool: add legacy sidecar conversion in reinject (#32688)
This adds the conversion for the legacy sidecar if these
transactions are reorged out after the osaka.
2025-09-23 14:45:36 +02:00
cui
a499a11a16
crypto: using testing.B.Loop (#32645)
before:
go test -run=^$ -bench=. ./crypto/... 94.83s user 2.68s system 138% cpu
1:10.55 tota

after:
go test -run=^$ -bench=. ./crypto/... 75.43s user 2.58s system 123% cpu
1:03.01 total
2025-09-19 17:12:41 -06:00
Marius van der Wijden
103b8b2ec5
crypto/bn256: switch to gnark again (#32659)
We recently update our default implementation to gnark in
https://github.com/ethereum/go-ethereum/pull/32024
Then we found a consensus issue and reverted it in
65d77c5129
We fixed the consensus issue and have been fuzzing it more since then in
https://github.com/ethereum/go-ethereum/pull/32055/files
https://github.com/ethereum/go-ethereum/pull/32065
https://github.com/ethereum/go-ethereum/pull/32055/files

So I think now is the time to update it back to gnark
2025-09-19 15:18:42 +02:00
Marius van der Wijden
df0bd8960c
core/txpool/blobpool: migrate billy to new slot size (#31966)
Implements a migration path for the blobpool slotter

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-09-15 21:34:57 +08:00
Felix Lange
cbf0b5bc92
go.mod, build: require go 1.24 and upgrade linter (#32584)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2025-09-11 13:07:04 +02:00
Zach Brown
2a795c14f4
all: fix problematic function name in comment (#32513)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
Fix problematic function name in comment.
Do my best to correct them all with a script to avoid spamming PRs.
2025-08-29 08:54:23 +08:00
cui
88922d2bf5
crypto/bn256: refactor to use bitutil.TestBytes (#32435)
Some checks are pending
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
2025-08-15 15:12:22 +08:00
cui
e798e26c69
crypto/secp256k1: use ReadBits from common/math (#32430) 2025-08-14 14:32:45 +02:00
cui
dfde155541
crypto/kzg4844: use reflect.TypeFor (#32319) 2025-08-07 14:22:11 +02:00
Felix Lange
b3131f00a3
core/vm: implement EIP-7951 - precompile for secp256r1 (#31991)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
https://github.com/ethereum/EIPs/pull/9833

Based on #27540, #30043

---------

Co-authored-by: Ulaş Erdoğan <uerdogan2001@hotmail.com>
2025-07-07 20:59:45 +02:00
Antonio Sanso
f26b5653e8
crypto/bn256: add documentation on subgroup checks for G2 (#32066)
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.
2025-06-20 13:18:20 +02:00
Marius van der Wijden
6723388b01
crypto/bn256/gnark: align marshaling behavior (#32065)
Aligns the marshaling behavior of gnark to google and cloudflare

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
2025-06-20 12:47:48 +02:00
Stephen Buttolph
0ce13346ce
crypto/bn256/cloudflare: pull in upstream fix for R27 and R29 usage (#32057)
Some checks are pending
/ Linux Build (arm) (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Docker Image (push) Waiting to run
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).
2025-06-18 14:17:30 +02:00
nthumann
cc1293b8f1
all: reuse the global hash buffer (#31839)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Docker Image (push) Waiting to run
As https://github.com/ethereum/go-ethereum/pull/31769 defined a global
hash pool, so we can reuse it, and also remove the unnecessary
KeccakState buffering

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-06-18 15:29:14 +08:00
Marius van der Wijden
6bba9d42a5
tests/fuzzers: added bn marshaling fuzzers (#32053)
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
2025-06-17 23:02:36 +02:00
kevaundray
190b236966
crypto/bn256: fix gnark deserialisation (#32055)
fixes the gnark deserialisation

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-06-17 21:58:31 +02:00
Felix Lange
65d77c5129 Revert "crypto/bn256: default to gnark (#32024)"
Some checks are pending
/ Linux Build (arm) (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Docker Image (push) Waiting to run
This reverts commit e0cf89ecfa.
2025-06-17 00:42:07 +02:00
kevaundray
e0cf89ecfa
crypto/bn256: default to gnark (#32024) 2025-06-16 13:10:14 +02:00
Marius van der Wijden
5605f9d7ad
crypto/kzg4844: remove kzg initialization (#32017)
This fixes a regression in the state tests where we always initialized
the KZG library. This was added to test some stuff in #31791
2025-06-12 17:53:16 +08:00
Marius van der Wijden
c7e6c08e54
eth/catalyst: implement getBlobsV2 (#31791)
Implements `engine_getBlobsV2` which is needed for PeerDAS.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-06-09 11:34:24 +02:00
Ömer Faruk Irmak
d675721276
crypto/kzg4844: avoid copying blobs for marshaling (#31911)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Docker Image (push) Waiting to run
LLVM is not able to handle large arrays on stack
2025-06-04 20:52:27 +02:00
Ömer Faruk Irmak
a53fdf1fe6
crypto: use pure Go signature implementation in tinygo (#31878)
tinygo is having problems compiling the C implementation
2025-05-23 11:14:40 +02:00
wellna
2cd5f22037
crypto/kzg4844: use package github.com/crate-crypto/go-eth-kzg (#31806)
I saw in https://github.com/ethereum/go-ethereum/pull/31378 introduced
github.com/crate-crypto/go-eth-kzg to calculate the kzg hash, and
github.com/crate-crypto/go-kzg-4844 was only used in the test files, so
propose to drop it with go-eth-kzg instead
2025-05-13 14:11:27 +02:00
Marius van der Wijden
0eb2eeea90
all: create global hasher pool (#31769)
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: Gary Rong <garyrong0905@gmail.com>
2025-05-09 13:52:40 +08:00
Marius van der Wijden
947fd3a834
crypto/kzg4844: add ComputeCells functionality (#31378)
For PeerDAS, we need to compute cell proofs. Both ckzg and gokzg support
computing these cell proofs.
This PR does the following:

- Update the go-kzg library from "github.com/crate-crypto/go-kzg-4844"
to "github.com/crate-crypto/go-eth-kzg" which will be the new upstream
for go-kzg moving forward
- Update ckzg from v1.0.0 to v2.0.1 and switch to /v2
- Updates the trusted setup to contain the g1 points both in lagrange
and monomial form
- Expose `ComputeCells` to compute the cell proofs
2025-04-29 14:42:17 +02:00
Marius van der Wijden
5606cbc710
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-12 12:21:50 +01:00
Marius van der Wijden
fbe0005070
crypto: add comment to FromECDSAPub (#31241)
closes https://github.com/ethereum/go-ethereum/issues/26240
2025-02-24 12:23:25 +01:00
levisyin
d103f179b9
build: replace tenv linter with usetesting (#31172) 2025-02-21 13:36:18 +01:00
Ryan Tinianov
9b9e7ccacf
all: add build tags for wasip1 (#31090) 2025-01-30 16:58:53 +01:00
Felix Lange
fa9a2ff868
crypto: add IsOnCurve check (#31100) 2025-01-30 14:10:36 +01:00
georgehao
1843f27766
all: fix some typos in comments and names (#31023) 2025-01-14 14:16:15 +01:00
gitglorythegreat
0feb999d3f
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-02 14:04:06 +01:00
kevaundray
74461aecf6
crypto, tests/fuzzers: add gnark bn254 precompile methods for fuzzing (#30585)
Makes the gnark precompile methods more amenable to fuzzing
2024-10-23 08:11:25 +02:00
Alex Gartner
30ce17386b
crypto: use decred secp256k1 directly (#30595)
Use `github.com/decred/dcrd/dcrec/secp256k1/v4` directly rather than
`github.com/btcsuite/btcd/btcec/v2` which is just a wrapper around the
underlying decred library. Inspired by
https://github.com/cosmos/cosmos-sdk/pull/15018

`github.com/btcsuite/btcd/btcec/v2` has a very annoying breaking change
when upgrading from `v2.3.3` to `v2.3.4`. The easiest way to workaround
this is to just remove the wrapper.

Would be very nice if you could backport this to the release branches.

References:
- https://github.com/btcsuite/btcd/issues/2221
- https://github.com/cometbft/cometbft/pull/4294
- https://github.com/cometbft/cometbft/pull/3728
- https://github.com/zeta-chain/node/pull/2934
2024-10-15 11:49:08 +03:00
Alexander Mint
df3f0a81a7
go.mod: upgrade to btcsuite/btcd/btcec v2.3.4 (#30181) 2024-07-18 12:38:42 +02:00
zhiqiangxu
c4b4d05e69
crypto: remove hardcoded value for secp256k1.N (#30126) 2024-07-09 13:19:25 +02:00
SuiYuan
2262bf3415
crypto/secp256k1: change receiver variable name to lowercase (#29889) 2024-05-30 16:24:16 +02:00
persmor
0a51028819
all: fix various typos (#29542)
* core/rawdb: fix typos

* accounts/abi: fix typos

* metrics: fix typo

* beacon: fix typo

* crypto: fix typo

* rpc: fix typo

* rpc: fix typo
2024-04-16 15:44:00 +03:00
Marius van der Wijden
f437307877
core/vm: update gascosts for BLS12-381 + use gnark instead of kilic (#29441)
This PR updates the bls contracts from our internal implementation which is an unmaintained fork of the kilic library to the gnark-crypto library that is actively maintained by consensys.

It also updates the gas-costs according to the EIP
2024-04-16 10:53:43 +02:00
Abirdcfly
b179b7b8e7
all: remove duplicate word in comments (#29531)
This change removes some duplicate words in in comments
2024-04-15 08:34:31 +02:00
guangwu
8bd0334168
crypto/signify: close tmp key file in test (#29444) 2024-04-04 12:20:54 +02:00
Aaron Chen
723b1e36ad
all: fix mismatched names in comments (#29348)
* all: fix mismatched names in comments

* metrics: fix mismatched name in UpdateIfGt
2024-03-26 21:01:28 +01:00
George Ma
38eb8b3e20
all: fix docstrings (#29311) 2024-03-22 20:29:12 +08:00
Martin HS
14eb8967be
all: use min/max/clear from go1.21 (#29307) 2024-03-21 13:50:13 +01:00