Skip to content

starknet_api: escape the Pedersen image in Blake2 contract address derivation - #14812

Draft
ron-starkware wants to merge 1 commit into
ron/contract-address/pluggable-hashfrom
ron/contract-address/pedersen-image-escape
Draft

starknet_api: escape the Pedersen image in Blake2 contract address derivation#14812
ron-starkware wants to merge 1 commit into
ron/contract-address/pluggable-hashfrom
ron/contract-address/pedersen-image-escape

Conversation

@ron-starkware

@ron-starkware ron-starkware commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Stack — part 2 of 9 (base: #14811). Targets 0.14.5.

Makes the Blake2 arm of calculate_contract_address escape the Pedersen image: the raw BLAKE2s address is incremented (wrapping mod L2_ADDRESS_UPPER_BOUND, skipping the reserved 0x0/0x1) until no Pedersen derivation can reach it.

A Pedersen output is always the x-coordinate of a STARK curve point, so the escaped address is provably unreachable by any Pedersen derivation — a funded-but-undeployed Blake2 address cannot be front-run through DeployAccount v1/v3 or the deploy syscall, even by an attacker with a discrete-log oracle. The two address spaces are therefore disjoint, and the scheme is readable off any address with one residuosity check.

  • pedersen_reachable(a) = is_curve_x(a) or (a < SECOND_LIFT_BOUND and is_curve_x(a + ADDR_BOUND)), with SECOND_LIFT_BOUND = p - ADDR_BOUND = 17·2^192 + 257.
  • BLAKE2s runs exactly once; each escape step is a square-root check, never a re-hash. Mean 1.02 increments over 20k random starts (max 17); the loop is deliberately uncapped.

Tests pin the five frozen derivation vectors (0/1/2/3/7 escape steps) and the pedersen_reachable truth table — the same vectors the Cairo OS, the cairo compiler (starkware-libs/cairo#10214) and cairo-native pin.

🤖 Generated with Claude Code

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale.
This PR will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

@ron-starkware
ron-starkware force-pushed the ron/contract-address/pluggable-hash branch from 85b0748 to dcefda7 Compare August 31, 2026 12:56
@ron-starkware
ron-starkware force-pushed the ron/contract-address/pedersen-image-escape branch from 34c036c to 0088e53 Compare August 31, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants