Skip to content

test(#248): reject all-zero admin pubkey on initialize - #619

Merged
Calebux merged 2 commits into
zintarh:mainfrom
EmannuellaO:feat/248-zero-admin-pubkey
Aug 7, 2026
Merged

test(#248): reject all-zero admin pubkey on initialize#619
Calebux merged 2 commits into
zintarh:mainfrom
EmannuellaO:feat/248-zero-admin-pubkey

Conversation

@EmannuellaO

Copy link
Copy Markdown
Contributor

Closes #248

Summary

The contract previously accepted any BytesN<32> as the admin signing key. An all-zero Ed25519 public key has no known corresponding private key, so accepting it would silently brick every future mint_wrap call (no valid signature could ever be produced) while leaving the contract in an initialized, degraded state.

This PR rejects the all-zero key at initialize time with a new contract error.

Changes

  • errors.rs: add InvalidAdminPubKey = 52.
  • admin.rs::initialize: panic with InvalidAdminPubKey when the provided pubkey is all-zero; document the rationale.
  • test.rs: add tests covering
    • all-zero admin pubkey is rejected (Error(Contract, #52)),
    • a rejected zero-key attempt does not leave the contract half-initialized — a subsequent valid initialize still succeeds.

Acceptance criteria

  • Add a test for all-zero admin pubkey initialization.
  • If rejected, add a contract error and update docs. (rejected)

Verification

  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings 0 errors
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps 0 errors
  • RUSTFLAGS="-D warnings" cargo test → 174 passed / 0 failed / 1 ignored + 1 integration test

Note: this branch is stacked on #618 (baseline SDK 27 repair) so CI can compile.

…revoke

Add a persistent per-user last-updated marker (DataKey::LastUpdated)
that records the ledger timestamp of the most recent successful mint
(mint_wrap / mint_wrap_batch) or revoke. Expose it via a new
get_last_updated query and cover it with monotonicity tests.

The baseline main branch did not compile against Soroban SDK 27 (broken
merge ec4e11a plus pre-existing drift), so this change also repairs the
crate to green: FSM transitions (Draft/Pending->Expired, Active->Pending
for bridging), strict expiry deadline semantics, updated contract-error
codes in tests, stake tests now set an explicit ledger timestamp (SDK 27
defaults it to 0), SDK 27 event-buffer reset handling, and clippy/fmt/doc
cleanliness (-D warnings).
An all-zero Ed25519 public key has no known private key, so accepting it
would silently brick every future mint_wrap call while leaving the
contract in an initialized state. Reject it at initialize time with a new
InvalidAdminPubKey error and cover the behavior with tests:
- zero admin pubkey is rejected (Error(Contract, zintarh#52))
- a rejected zero-key attempt leaves the contract uninitialized so a
  valid initialize still succeeds
@drips-wave

drips-wave Bot commented Aug 1, 2026

Copy link
Copy Markdown

@EmannuellaO Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Calebux
Calebux merged commit 02e16b5 into zintarh:main Aug 7, 2026
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.

test: Cover initialize with zero-like admin pubkey

2 participants