Skip to content

Commit 9876b26

Browse files
committed
Adding the RSKIP-552 content improvements about blake2f
1 parent 4e9cd72 commit 9876b26

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
_site
22
.sass-cache
33
.jekyll-metadata
4+
.DS_Store/
5+
.idea/

IPs/RSKIP552.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,67 @@
11
---
22
rskip: 552
3-
title: Title
3+
title: Improve Blake2F Input Validation
44
created: 16-MAR-26
55
author: FML (@fmacleal)
6-
purpose: Sca,Usa,Fair,Sec or ST
7-
layer: Core
6+
purpose: Sec
7+
layer: Core
88
complexity: 1
9-
status: Draft,Accepted,Adopted,Deferred or Rejected
10-
description:
9+
status: Draft
10+
description: Add null-safety checks to Blake2F precompiled contract input handling
1111
---
1212

13-
|RSKIP | 552 |
14-
| :------------ |:--------------------------------------------|
15-
|**Title** | Title |
16-
|**Created** | 16-MAR-26 |
17-
|**Author** | FML |
18-
|**Purpose** | Sca,Usa,Fair,Sec or ST |
19-
|**Layer** | Core |
20-
|**Complexity** | 1 |
21-
|**Status** | Draft,Accepted,Adopted,Deferred or Rejected |
13+
# Improve Blake2F Input Validation
14+
15+
|RSKIP | 552 |
16+
| :------------ |:---------------------------------------------|
17+
|**Title** | Improve Blake2F Input Validation |
18+
|**Created** | 16-MAR-26 |
19+
|**Author** | FML |
20+
|**Purpose** | Sec |
21+
|**Layer** | Core |
22+
|**Complexity** | 1 |
23+
|**Status** | Draft |
2224

2325
## Abstract
2426

25-
To be completed...
27+
This RSKIP improves the input validation of the Blake2F precompiled contract (address `0x0000000000000000000000000000000000000009`) introduced by [RSKIP-153](https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP153.md). The change ensures that the Blake2F precompile handles all possible calldata states correctly, including edge cases not covered by the original implementation. Additionally, the exception handling in the precompile execution path within the EVM is improved to increase robustness.
2628

2729
## Motivation
2830

29-
To be completed...
31+
The Blake2F precompiled contract, enabled via RSKIP-153, expects calldata of exactly 213 bytes. The precompile validates the input length before proceeding. However, the current implementation does not handle all possible calldata edge cases consistently.
32+
33+
To ensure the Blake2F precompile handles all possible input states consistently and deterministically, explicit validation should be added for edge cases not covered by the original implementation. This aligns the precompile with defensive programming best practices and strengthens the overall robustness of the consensus execution path.
3034

3135
## Specification
3236

33-
To be completed...
37+
This RSKIP introduces the following changes, activated conditionally via a new consensus rule (`RSKIP552`):
38+
39+
### 1. Improved input validation in gas calculation
40+
41+
When `RSKIP552` is active, the gas calculation logic for the Blake2F precompile handles all possible input states, including edge-case calldata. Invalid inputs return zero gas, consistent with the existing behavior for malformed input of incorrect length.
42+
43+
### 2. Improved input validation in execution
3444

35-
### Subsection 1 of Specification such as format.
45+
When `RSKIP552` is active, the execution logic for the Blake2F precompile handles all possible input states. Edge-case calldata is rejected with the existing error for incorrect input length, consistent with how other malformed inputs are handled.
3646

37-
To be completed...
47+
### 3. Improved exception handling in precompile execution
48+
49+
The exception handling in the EVM's precompile execution path is improved to ensure that all error conditions during precompile execution are properly caught and handled, resulting in the call returning zero to the caller.
50+
51+
## Backward Compatibility
52+
53+
This change is activated via a consensus rule (`RSKIP552`) and will take effect at a specific network upgrade block height. Before activation, the behavior of the Blake2F precompile remains unchanged. After activation, the only behavioral difference is that transactions targeting the Blake2F precompile with edge-case calldata will be handled consistently with other malformed-input scenarios.
3854

3955
## Rationale
4056

41-
Discuss design decisions, community debates and possible attacks.
57+
Precompiled contracts should handle all possible input states gracefully, following the principle of defensive input validation. This change ensures that the Blake2F precompile behaves consistently and deterministically regardless of how the calling transaction is encoded.
4258

4359
## References
4460

45-
[1] Other RSKIP https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP??.md
61+
[1] [RSKIP-153 - Add BLAKE2 Compression Function F Precompile](https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP153.md)
62+
63+
[2] [EIP-152 - BLAKE2b F Compression Function](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md)
4664

4765
### Copyright
4866

49-
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
67+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)