-
Notifications
You must be signed in to change notification settings - Fork 26
Shielded AccessControl #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 250 commits
Commits
Show all changes
365 commits
Select commit
Hold shift + click to select a range
81ebb9f
add ledger and witness docs
andrew-fleming c5417c1
Revert "Add contractAddress to nonce generation scheme"
emnul db5821f
Update hashing scheme
emnul 98c86db
Update hash function in witness
emnul b556fad
improve computeOwnerId assertion
andrew-fleming a880f8d
use _computeOwnerId in assertOnlyOwner
andrew-fleming de69018
fix fmt
andrew-fleming 92b46a8
add wrapAsEither circuits
andrew-fleming 9fc5bbe
add option to compile directory in compact
andrew-fleming 98b7a32
add granular compile scripts
andrew-fleming ae9e311
fix fmt
andrew-fleming 4a9885b
use fast compilation prior to tests, cache tests
andrew-fleming 6fb3f74
add circuit tag
andrew-fleming 6161001
fix conflicts
andrew-fleming 2ac92b5
move ZOwnablePK witness interface
andrew-fleming db87258
improve in-code docs
andrew-fleming 9d78542
add ZOwnablePK api
andrew-fleming 96f95c9
add withNonce to PS
andrew-fleming c16cd7d
add ZOwnablePK docs (less setup)
andrew-fleming 3586158
improve sec prop section
andrew-fleming 33148b0
fix fmt
andrew-fleming 71ad93f
add usage section
andrew-fleming d707d28
revert changes
andrew-fleming e018e03
fix typo
andrew-fleming d113802
update readme with targeted compilation
andrew-fleming b3a0bd4
add k and rows
andrew-fleming f3e2872
add constraints to docs
andrew-fleming 7b57e93
add SKIP_ZK env var to compile
andrew-fleming 822fcd6
improve docs
andrew-fleming 1c36f67
update README
andrew-fleming c676fd0
Apply suggestions from code review
andrew-fleming 0cd3c59
change generic H to SHA256 in docs
andrew-fleming 06f3c83
change generic H to SHA256
andrew-fleming 8e28bda
fix lang version in mock
andrew-fleming 9b3e97c
add bad owner id hash scenario
andrew-fleming 35d95d3
Merge branch 'main' into shielded-access-control
emnul 490af83
Apply suggestions from code review
andrew-fleming 018ba5c
improve create proxy constraints, cast circuits to the extracted type…
andrew-fleming 12a06c7
Apply suggestions from code review
andrew-fleming 1b55a09
Remove old dir, rename files
emnul 8e5dd6b
Apply suggestions from code review
andrew-fleming b100b9e
add AGPK section
andrew-fleming 15aff68
fix guide links in access api, add agpk ref
andrew-fleming 524dab9
add agpk recommendation
andrew-fleming 7ba770d
WIP Experimental re-design
emnul a3e6a3a
add descriptions to circuits in sim
andrew-fleming a22ba6c
fix sim state mngr, improve docs
andrew-fleming 37bb7aa
fix fmt
andrew-fleming 02227ab
add non-deterministic sig warning
andrew-fleming b584c53
add period
andrew-fleming 418a7b5
improve agpk principles
andrew-fleming bd18c19
improve clarity on 'never used elsewhere'
andrew-fleming acf3397
add wit_ prefix to witnesses
andrew-fleming 8489924
Apply suggestions from code review
andrew-fleming 67972b9
remove artifacts from inputs
andrew-fleming f23e56a
fix fmt
andrew-fleming efaa2a0
Apply suggestions from code review
andrew-fleming be5b418
Merge branch 'main' into improve-turbo-restructure
andrew-fleming a902206
Merge branch 'main' into shielded-access-control
emnul 7ad70e6
Merge branch 'improve-turbo-restructure' into shielded-access-control
emnul eb3d4bc
rebase
andrew-fleming 32a80ff
Merge branch 'add-ownable-shielded' of https://github.com/andrew-flem…
emnul 365b7fd
Merge branch 'main' into shielded-access-control
emnul e48e6b8
Merge branch 'add-ownable-shielded' into shielded-access-control
emnul c16a6be
Construct simulator and witnesses for impl
emnul 5882005
Merge branch 'main' into shielded-access-control
emnul 9117fc6
Restrict usage to ZSwapCoinPubKeys, simplify logic
emnul e77d127
Update *.compact testing dependencies
emnul 0c33611
Add helper fn, update API for improved flexibility
emnul e3cb30d
Use helper in witness impl
emnul 95821e0
Init tests
emnul 52000a2
Update simulator initialization
emnul 3af7b9a
Update hashing scheme
emnul 8d23061
Fix incorrect default MerkleTreePath construction
emnul 47f5d3e
Improve typesafety of try catch block, add debugging logic
emnul c607923
Add initialization checks, correct role commitment checks
emnul dc5aed7
Merge branch 'main' into shielded-access-control
emnul 4140f3b
Use correct MT API
emnul 67f36aa
Add utility fn and improve logging
emnul 99fa0be
add test
emnul 4b1ff86
Fix typo in filename
emnul 9a735b2
Update imports
emnul 2f375ba
Update witness fn signatures
emnul a5a1763
Update constructor, witnesses setter
emnul 353b379
Add bad index tests
emnul 1fa7122
Merge branch 'main' into shielded-access-control
emnul 26d3576
Update Role field name
emnul da274c4
Add tests
emnul 7ae6407
Remove _unsafeGrantRole
emnul 5a1b0b4
Improve tests
emnul 923d779
Add helper method
emnul 07dd40b
Change privateState fn signatures
emnul fdcf13c
Add tests
emnul b08a600
Merge branch 'main' into shielded-access-control
emnul 7e6a6a0
Should not throw if commitment in nullifer set
emnul 8e5c26f
Export nullifiers for testing
emnul dd0cd82
Rename var and change return behavior
emnul f24eeb0
Add _checkRole, grantRole tests
emnul 2cb227e
fmt files
emnul 061ac4a
WIP
emnul a98144e
Update contracts/src/access/witnesses/ShieldedAccessControlWitnesses.ts
emnul 9d9c256
Optimize loop
emnul 52936ef
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 5d2da06
Refactor Shielded Design
emnul 713d3d4
Move resetProxy call to end of fn
emnul 8a5fbba
Fixes incorrect indexing bug
emnul 2fce76c
WIP refactor tests
emnul 306ec1f
Merge branch 'main' into shielded-access-control
emnul 2fb86e7
Fix compiler errors, refactor mock and witnesses
emnul a2e644d
Refactor test suite
emnul 16928c3
Refactor simulator for new design
emnul 740bb83
WIP
emnul a6feeff
Remove old
emnul ccdbe85
Merge branch 'main' into shielded-access-control
emnul 7df0378
Remove unused file
emnul a6f0eaa
WIP
emnul dc5001f
Use standard insert method over insertHash
emnul 5a817c9
Update circuit docs
emnul 88355c8
Improve naming, remove dead code, narrow circuit responsibility
emnul 266e0fd
Update module docs
emnul efdf636
Add nominal type aliases
emnul 1186e51
Refactor witness file
emnul e819d8d
Change prefix
emnul 1b59084
Refactor simulator
emnul aef1ed3
Update error message
emnul 1f3349d
rename param
emnul d4f6b8d
Refactor tests
emnul e67fc4a
Add Initializable
emnul 01153f0
Refactor sim
emnul 1a3bb3d
improve naming
emnul bf99e94
WIP refactor tests
emnul 16b0ecd
Add helper methods to sim
emnul 5ddbe1e
Enforce single use role commitments
emnul f91d346
WIP tests
emnul b541593
Refactor docs
emnul 13d142c
move disclosure closer to disclosure point
emnul a5268f6
Reduce metadata leakage
emnul 6a4d55e
Update witness file
emnul 82170b8
Export circuit from Mock
emnul f3279b4
Update simulator
emnul 0be3e5c
Update method name, assert Initialized in computeAccountId
emnul 5c67ac8
fmt file
emnul 9601c4d
Add assertion to _checkRole
emnul 8053d17
fmt file
emnul 287f7bb
Update default Merkle tree value
emnul 8aedd88
Simplify return statement
emnul d80091b
fmt files
emnul d3fa7f7
reorganize code, inline auth logic in _grant/revokeRole
emnul 3a016b1
Update circuit info
emnul 3bb9e4c
WIP commit
emnul e3cf7e9
Revert "WIP commit"
emnul 1c5f803
Reapply "WIP commit"
emnul 8d9713a
WIP commit
emnul ae13104
Merge branch 'main' into shielded-access-control
pepebndc ecbe0da
Add tests for shielded access control
pepebndc a34d7f5
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul d081342
Assert instance salt is not 0
emnul dc8b522
Merge remote-tracking branch 'origin/feat/tests-shielded-access-contr…
emnul 154938e
Apply suggestions from code review
emnul c7b3d2a
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 3cfa7af
strange compact compiler bug
emnul a5fe6d1
add tests
emnul ac33519
update assertion message
emnul 12818f8
Sync mock implementation
emnul e5b402d
update tests
emnul a10b9bb
big refactor
emnul 09e4a21
Remove unused witness
emnul 813fa99
update simulator
emnul 36a6d0a
refactor tests
emnul f2ee664
Update description
emnul 1a74761
Update test
emnul 67b85d1
Refactor contract
emnul 8fefb4e
Refactor simulator
emnul e8ba943
refactor: harden the shieldedaccesscontrol lib by some improvements a…
0xisk 81002bf
Revert "refactor: harden the shieldedaccesscontrol lib by some improv…
0xisk d67a369
fmt files, add export to mock
emnul 7546ffd
Add additional documentation
emnul 5f654fc
remove unused types
emnul ac1077a
Add tests and lint files
emnul bec51ca
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 4757096
fmt file
emnul 187f23f
add test
emnul 593bcc0
refactor files: roleId -> role
emnul b775993
rm old tests
emnul 4e59f2b
Merge branch 'main' into shielded-access-control
pepebndc 196843e
Simplify internal circuit signature
emnul 036c66c
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 1900f04
Remove initialization checks from internal circuits
emnul fcb9a16
Revert "Remove initialization checks from internal circuits"
emnul fbe1df8
Reapply "Remove initialization checks from internal circuits"
emnul 80dd34d
Update docs reorganize code
emnul d38c6dc
Add unchecked circuits
emnul 1b6c2a5
remove init checks from get / set admin circuits
emnul 819c821
fix circuit def
emnul 15a113b
Add unexported circuits to mock
emnul 8f536e0
Fmt Mock
emnul 452c2d9
Add _uncheckedCircuits to sim, tests, fix mock export
emnul d989f34
Remove admin identifier
emnul ac4853d
Update docs
emnul c7d06c0
remove ledger artifact from wit, update sim
andrew-fleming 7e27f80
remove ledger artifact from wit, update sim in zownable
andrew-fleming 7ea82e9
update sim readme
andrew-fleming c74f42f
add changelog entry
andrew-fleming f802a54
improve witness docs
andrew-fleming bcb4ce1
update changelog
andrew-fleming 1b4f5c3
Merge branch 'main' into remove-artifact-ledger-from-witnesses
andrew-fleming 72ed9a5
refactor: test should compare circuit result not callback
emnul bbbdba9
refactor: test should compare root value not object
emnul 9ed5fec
refactor: DEFAULT_ADMIN_ROLE into pure circuit
emnul 85c71d9
Update mock, sim, and tests with DEFAULT_ADMIN_ROLE circuit
emnul bc2d635
Update type
emnul dbdff4c
Update contracts/src/access/witnesses/ShieldedAccessControlWitnesses.ts
emnul b407b7c
Add matcher for assertion
emnul 67b4753
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 6d6e064
Throw error if role nonce is undefined
emnul 7e5f144
Add README to contracts directory
emnul e001b10
Add disclaimer to all Mock files
emnul dc3737e
Update contracts/src/access/ShieldedAccessControl.compact
emnul 7c1427a
Update circuit requirements
emnul 99b18c6
Refactor: Remove _uncheckedAssert, keep _grant / _revoke DRY
emnul 75e6dcb
Refactor: remove references to _uncheckedAssert
emnul 72fa7b3
Remove warning from pure circuit
emnul b2defa9
revert changes to simulator test utils
emnul 79ad5a3
rename circuit
emnul 944d251
Update circuitInfo
emnul 9c86e1a
Remove tests
emnul 8c6ad6d
Merge branch 'main' into shielded-access-control
emnul e7f5be1
Merge branch 'remove-artifact-ledger-from-witnesses' into shielded-ac…
emnul bc1ded2
Use generic witness pattern
emnul 748ee62
Add interface to computeAccountId locally, export _computeNullifier a…
emnul a7566b1
Update tests and simulator
emnul d24eae9
Remove README
emnul 7b2ef89
Merge branch 'main' into shielded-access-control
emnul 8c8ea72
Update contracts/src/access/ShieldedAccessControl.compact
emnul c5b34f6
Update contracts/src/access/ShieldedAccessControl.compact
emnul 38b4696
Update contracts/src/access/ShieldedAccessControl.compact
emnul cc56b39
Update contracts/src/access/ShieldedAccessControl.compact
emnul dbc85f4
update _setRoleAdmin docs
emnul 8a21058
Merge branch 'shielded-access-control' of https://github.com/OpenZepp…
emnul 7729e67
Update circuit _computeNull and _computeRoleCom names
emnul 9bd47ea
Refactor names in tests / sim
emnul 28cc91e
Refactor _computeAccountId to depend on pure variant, rename pure var…
emnul ea50c07
Update error message
emnul 9d7f148
Merge branch 'main' into shielded-access-control
0xisk 00d521b
chore: add warning for the exported grant and revoke functions
0xisk dcf6e7e
chore(access): same ordering everywhere (#410)
0xisk 3c41f95
refactor(access): adding more test cases for shielded access control …
0xisk 6c3f220
Merge branch 'main' into shielded-access-control
andrew-fleming a7a9aa4
Refactor shielded access (#412)
andrew-fleming 0366037
Merge branch 'main' into shielded-access-control
andrew-fleming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Contracts README | ||
|
|
||
| This package contains the Compact smart contract source files, compiled artifacts, witness implementations, and test infrastructure for OpenZeppelin Contracts for Compact. | ||
|
|
||
| ## Directory Structure | ||
|
|
||
| ``` | ||
| contracts/ | ||
| ├── src/ # Source files | ||
| │ ├── access/ # Access control contracts | ||
| │ ├── security/ # Security utility contracts | ||
| │ ├── token/ # Token standard contracts | ||
| │ ├── utils/ # General utility contracts | ||
| │ ├── archive/ # Archived/deprecated contracts | ||
| │ └── test-utils/ # Shared test helpers | ||
| ├── artifacts/ # Compiled contract outputs (generated) | ||
| └── dist/ # Compiled TypeScript witness outputs (generated) | ||
| ``` | ||
|
|
||
| ## src/ | ||
|
|
||
| The `src/` directory is organized by module category. Each module follows the same internal layout: | ||
|
|
||
| ``` | ||
| <module>/ | ||
| ├── <Contract>.compact # Contract source | ||
| ├── witnesses/ # TypeScript witness implementations | ||
| └── test/ | ||
| ├── <Contract>.test.ts # Test suite | ||
| ├── mocks/ # Mock contracts (test-only — see warning below) | ||
| └── simulators/ # Simulator helpers for testing | ||
| ``` | ||
|
|
||
| ### src/access/ | ||
|
|
||
| Access control primitives for restricting who can call contract circuits. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `AccessControl.compact` | Role-based access control | | ||
| | `Ownable.compact` | Single-owner access control | | ||
| | `ShieldedAccessControl.compact` | Role-based access control with shielded (private) role assignments | | ||
| | `ZOwnablePK.compact` | Single-owner access control with shielded ownership | | ||
|
|
||
| ### src/security/ | ||
|
|
||
| Contracts that add common security patterns on top of other modules. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `Initializable.compact` | One-time initialization mechanism | | ||
| | `Pausable.compact` | Emergency pause/unpause mechanism | | ||
|
|
||
| ### src/token/ | ||
|
|
||
| Implementations of standard token interfaces. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `FungibleToken.compact` | ERC-20-style fungible token | | ||
| | `NonFungibleToken.compact` | ERC-721-style non-fungible token | | ||
| | `MultiToken.compact` | ERC-1155-style multi-token | | ||
|
|
||
| ### src/utils/ | ||
|
|
||
| Low-level utilities shared across modules. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `Utils.compact` | Common helper circuits | | ||
|
|
||
| ### src/archive/ | ||
|
|
||
| Contracts that are no longer actively maintained. Do not use in new projects. | ||
|
|
||
| ### src/test-utils/ | ||
|
|
||
| Shared TypeScript helpers used across test suites (e.g. address utilities). Not part of the public API. | ||
|
|
||
| --- | ||
|
|
||
| ## > ⚠️ Mock Contracts Are For Testing Only | ||
|
|
||
| Each module's `test/mocks/` directory contains `Mock*.compact` files (e.g. `MockFungibleToken.compact`, `MockOwnable.compact`, `MockAccessControl.compact`). | ||
|
|
||
| **These contracts exist solely to expose internal state and circuits for testing purposes. They must never be used in production.** | ||
|
|
||
| Mock contracts typically: | ||
| - Expose internal or protected circuits publicly for direct testing | ||
| - Skip access control or safety checks to isolate specific behaviors | ||
| - Introduce additional state that makes testing easier but is unsafe in deployment | ||
|
|
||
| **Using a Mock contract in production would undermine the security guarantees the corresponding production contract is designed to provide.** |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose adding the contracts/README into another PR. It's better organizational discipline since it's not directly related to the feature and it's worth its own discussion to not muddy up this already noisy PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on this. This PR is taking longer than anticipated, and if we can split additional elements into their independent flows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this change to #403