OpenZeppelin / OpenZeppelin/compact-contracts

dev: `transferFrom` circuit optimization

Open
#864 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1-medium enhancement
Dominant language
TypeScript
Stars
55
Forks
29
Avg merge
5d 7h
Merged PRs (30d)
25

Description

transferFrom optimization

followup: the five-field persistentHash(seed, tag, owner, spender, epoch) costs one more SHA-256 block per scalar than the two-field expandRandomness it replaces, so transferFrom goes 63207 → 70164 rows and over the k=16 boundary. k=17 doubles its proving table, and the header two hundred lines up already warns the full CFT surface exceeded the local ledger-8 block byte budget.

This PR introduces the derivation, so it is not pre-existing debt. Hashing (owner, spender, epoch) once into a 32-byte nonce and expanding that three times should hold k=16; worth measuring before this lands on the release branch rather than tracking it after.

added by claude (dev3-midnight-basic-review)

Originally posted by @0xisk in https://github.com/OpenZeppelin/compact-contracts/pull/825#discussion_r3932254542

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the transferFrom implementation and its persistentHash and expandRandomness derivation, then establish the current circuit-row measurement and k=16 boundary. Compare the proposed nonce derivation by measuring the resulting rows and confirm that the CFT surface remains within the ledger-8 block byte budget before release.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain, cryptography
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.