Skip to content

docs: add security and best practices guide (modular assembly) - #1166

Merged
oduameh merged 6 commits into
mainfrom
docs/security-best-practices
Aug 5, 2026
Merged

docs: add security and best practices guide (modular assembly)#1166
oduameh merged 6 commits into
mainfrom
docs/security-best-practices

Conversation

@oduameh

@oduameh oduameh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Add docs/guides/security-best-practices.mdx, a how-to guide for DApp
developers covering the operational and design-level security decisions
not in the Compact language reference: threat model, viewing-key
protection, derived-identity authentication over ownPublicKey(), access
control, secret-key lifecycle, block-time deadlines, replay prevention,
anonymity sets, and front-running mitigation. Register the new route in
packages/tests/pipelines-urls.json.

All Compact snippets compiled (compiler 0.31.1) and load-bearing
behaviors executed against compact-runtime 0.16.0; viewing-key and
on-chain visibility claims verified against ledger, indexer, and wallet
source.
@oduameh
oduameh requested review from a team as code owners July 31, 2026 12:02
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
midnight-wiki Ready Ready Preview Aug 4, 2026 1:07pm

Request Review

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Status Count
🔍 Total 33
🔗 Unique 27
✅ Successful 16
⏳ Timeouts 0
🔀 Redirected 1
👻 Excluded 0
❓ Unknown 0
🚫 Errors 17
⛔ Unsupported 0

Errors per input

Errors in docs/guides/security-best-practices.mdx

  • [ERROR] error: (at 642:3) | Cannot resolve root-relative link '/sdks/community/openzeppelin-compact-contracts': To resolve root-relative links in local files, provide a root dir
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/reference/explicit-disclosure (at 215:368) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/reference/explicit-disclosure (at 641:3) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/smart-contract-security (at 17:362) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/smart-contract-security (at 26:71) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/smart-contract-security (at 639:3) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/smart-contract-security#input-validation-and-access-control (at 304:46) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/compact/test-and-debug (at 643:3) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/concepts/how-midnight-works/keeping-data-private (at 640:3) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/concepts/how-midnight-works/keeping-data-private#the-commitmentnullifier-pattern (at 469:328) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/getting-started/hello-world (at 23:76) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/getting-started/installation (at 24:7) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/guides/configure-providers (at 644:3) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/guides/making-decision-on-contract-updatability (at 634:127) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/tokens/shielded-token (at 113:295) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/tutorials/bboard/smart-contract (at 469:452) | File not found. Check if file exists and path is correct
  • [ERROR] file:///home/runner/work/midnight-docs/midnight-docs/docs/tutorials/bship/test-suite (at 626:131) | File not found. Check if file exists and path is correct

Redirects per input

Redirects in docs/guides/security-best-practices.mdx

Full Github Actions output

Comment thread docs/guides/security-best-practices.mdx
Comment thread docs/guides/security-best-practices.mdx
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Deployment Ready

🔗 Preview URL: https://pr-1166-midnight-docs.vercel.app

📝 Latest commit: 23e1054
Updated: Jul 31, 2026, 2:23 PM UTC


This preview updates automatically when you push new commits to this PR.

Restructure docs/guides/security-best-practices.mdx into a task-oriented
how-to: introduction, prerequisites, and four stepped procedures
(authenticate a caller, restrict a circuit to a group, enforce a
deadline, prevent replay), each ending in a verification step that runs
an actual test proving the mitigation holds. Keep the threat-model
table, viewing-key guidance, and pre-deployment checklist.

Every verification test was executed with Vitest against
compact-runtime 0.16.0 (4 files, 8 tests passing); every Compact
snippet compiles with compiler 0.31.1.
@oduameh oduameh changed the title docs: add security and best practices guide docs: add security and best practices how-to guide Jul 31, 2026
Comment thread docs/guides/security-best-practices.mdx
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
…oving

Add four sections to the security how-to: a "Validate inputs and
arithmetic" procedure (Compact traps subtraction underflow and widens
addition to prevent silent overflow), a "Let owners rotate a key"
recovery procedure, guidance on designing for durable and bounded state
(persistent vs transient hashes, unbounded Set/Map growth), and guidance
on proving without leaking private data (the proof server sees your
private witness inputs, so local proving keeps them on your machine).
Expand the pre-deployment checklist accordingly.

All new verification tests executed with Vitest against
compact-runtime 0.16.0 (13 tests passing total); every snippet compiles
with compiler 0.31.1. Viewing-key and proving-trust claims verified by
source inspection of midnight-ledger, midnight-js, and the connector API.
Comment thread docs/guides/security-best-practices.mdx
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Rebuild the guide on the Red Hat modular documentation model: one
monolith assembly composed of typed modules, each marked with a
_mod-docs-content-type comment. Four concept modules explain threats and
mechanisms, six procedure modules give numbered steps with a Verification
section that runs a real test, and five reference modules provide lookup
tables. Drop the Step component in favor of plain numbered procedure
steps.

Content and verification are unchanged from the prior pass: all Compact
snippets compile with compiler 0.31.1, and the 13 Vitest tests still pass
against compact-runtime 0.16.0.
@oduameh oduameh changed the title docs: add security and best practices how-to guide docs: add security and best practices guide (modular assembly) Jul 31, 2026
Comment thread docs/guides/security-best-practices.mdx
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Comment thread docs/guides/security-best-practices.mdx Outdated
Correctness fixes from review (nstanford5):
- Clarify that disclose() does not publish a value on its own; a value
  becomes public only when it crosses a public position (ledger write,
  exported-circuit return, or contract-to-contract call). Update the
  on-chain visibility row and add a note.
- Show that a secret can be supplied as a circuit argument (private by
  default), not only via a witness; witness != private state. Add a
  verified argument variant.
- State the correct reason disclose() is required (writing a private
  value to a public position), not merely that the value is
  witness-derived.

Also rewrite passive-voice, second-person, and weak-word constructions to
active voice: 0 Vale errors.
@oduameh
oduameh requested a review from nstanford5 July 31, 2026 14:15
Comment thread docs/guides/security-best-practices.mdx
@oduameh
oduameh merged commit 2cbf129 into main Aug 5, 2026
12 of 13 checks passed
@oduameh
oduameh deleted the docs/security-best-practices branch August 5, 2026 08:47
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.

3 participants