Skip to content

feat: discord - #34

Merged
benceharomi merged 2 commits into
mainfrom
discord
Mar 9, 2026
Merged

benceharomi merged 2 commits into
mainfrom
discord

Conversation

@benceharomi

@benceharomi benceharomi commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added Discord platform support with handle extraction capabilities from Discord email messages.
    • Implemented Discord-specific deployment and verification configuration.
  • Tests

    • Added comprehensive test fixtures and regex modules for Discord handle and sender domain validation.
    • Introduced Honk verifier infrastructure for circuit proof verification.

@coderabbitai

coderabbitai Bot commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR introduces Discord-specific support for the ZK email authentication system, including a Solidity deployment script, test fixtures, Noir circuits for regex-based email field extraction, and a Honk verifier contract for proof verification.

Changes

Cohort / File(s) Summary
Solidity Deployment
script/DeployLinkHandleEntrypoint/DeployLinkHandleEntrypointDiscord.s.sol
New deployment script extending base entrypoint deployer, overriding internal methods to configure HonkVerifier deployment, DKIM registry address (Sepolia), platform name ("Discord"), and record name ("com.discord").
Test Fixtures
test/fixtures/linkHandleCommand/LinkHandleCommandTestFixture.sol
Added getDiscordFixture() accessor method for retrieving platform-specific Discord test fixture data.
Noir Configuration & Metadata
test/fixtures/linkHandleCommand/discord/Nargo.toml, test/fixtures/linkHandleCommand/discord/files/blueprint.json
Package manifest defining dependencies (zkemail, zkregex, poseidon) and JSON blueprint specifying parsing rules for extracting Discord handle and sender domain from email headers and body with length constraints (64 bytes max) and regex patterns.
Noir Circuits
test/fixtures/linkHandleCommand/discord/src/handle_regex.nr, test/fixtures/linkHandleCommand/discord/src/sender_domain_regex.nr, test/fixtures/linkHandleCommand/discord/src/main.nr
Noir modules implementing NFA-based regex matching for handle and sender domain extraction, with transition tables and capture group logic; main circuit enforces DKIM signature and body hash verification, decodes body, computes pubkey hash and email nullifier, and returns combined regex capture results.
Honk Verifier
test/fixtures/linkHandleCommand/discord/target/HonkVerifier.sol
Comprehensive Solidity verifier contract implementing Ultra Honk proof verification with cryptographic primitives, transcript generation, relation checks, commitment scheme utilities, and proof parsing for validating circuit proofs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: generic platform handling #35: Implements generic platform handling framework that this Discord-specific PR extends and instantiates through deployment script overrides, fixture structure, and entrypoint/command verifier patterns.

Suggested reviewers

  • zkfriendly

Poem

🐰 Discord calls, and zk-hops reply,
Regex patterns weave through the Noir sky,
Honk verifiers hop with cryptographic grace,
Email proofs now find their place,
A bunny's delight—secrets on the blockchain! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: discord' is vague and does not clearly describe what is being added or changed beyond the platform name. Consider making the title more descriptive, such as 'feat: add Discord link handle entry point and fixtures' to clarify the scope and purpose of changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch discord

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Feb 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benceharomi
benceharomi force-pushed the generic-platform-handling branch from 053d3a5 to 53db751 Compare February 20, 2026 19:54
Base automatically changed from generic-platform-handling to main February 24, 2026 13:32
@benceharomi
benceharomi marked this pull request as ready for review February 24, 2026 13:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (1)
script/DeployLinkHandleEntrypoint/DeployLinkHandleEntrypointDiscord.s.sol (1)

12-15: Hardcoded Sepolia DKIM registry address lacks chain ID safeguard.

Both the Discord and Twitter implementations use the same hardcoded "sepolia always valid" address without assertion. While the base script's comments indicate this is intentionally network-specific, adding a chain ID check would prevent accidental deployment on other networks.

Optional chain guard
-    function _getDkimRegistryAddress() internal pure override returns (address) {
-        // sepolia always valid dkim registry
-        return 0xc4f628496b8c474096650C8f9023954643cC614F;
-    }
+    function _getDkimRegistryAddress() internal view override returns (address) {
+        require(block.chainid == 11155111, "Sepolia only");
+        return 0xc4f628496b8c474096650C8f9023954643cC614F;
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@script/DeployLinkHandleEntrypoint/DeployLinkHandleEntrypointDiscord.s.sol`
around lines 12 - 15, The hardcoded Sepolia DKIM registry in
_getDkimRegistryAddress needs a chain guard: inside the function (or immediately
before returning) assert that block.chainid == 11155111 (Sepolia) and revert or
revert with a clear message if not, so the address cannot be used on other
chains; keep returning 0xc4f628496b8c474096650C8f9023954643cC614F when the chain
ID check passes and add a brief comment indicating this is Sepolia-only.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/fixtures/linkHandleCommand/discord/files/blueprint.json`:
- Around line 26-39: The regexDef "(?:\\r\\n|^)from:[^\\r\\n]*@" is
case‑sensitive and will miss headers like "From:"; update the pattern used in
the parts array (the regexDef entry) to match header names case‑insensitively —
for example add an inline case‑insensitive flag like
"(?i)(?:\\r\\n|^)from:[^\\r\\n]*@" or use a case‑insensitive class (e.g.
"(?:\\r\\n|^)(?i:from):[^\\r\\n]*@"); alternatively normalize header names to
lowercase before running the existing regex in the code that consumes this
blueprint (where the parts array is used).

In `@test/fixtures/linkHandleCommand/discord/Nargo.toml`:
- Around line 1-5: This Nargo.toml under test fixtures is a generated artifact
(package entry "zkemail/discord_2@1" / manifest content) and must not be edited
manually; revert any changes to this Nargo.toml and update the generator or
source-of-truth that produces fixtures (the tool or script that emits the
package/type/authors/compiler_version fields) so future regenerations reflect
the intended values—locate the fixture generator that outputs the Nargo.toml for
linkHandleCommand/discord and make the fix there rather than editing the
generated Nargo.toml directly.

In `@test/fixtures/linkHandleCommand/discord/src/handle_regex.nr`:
- Around line 1-6: handle_regex.nr is a generated fixture and should not be
edited directly; instead update the generator/template that emits files under
test/fixtures/linkHandleCommand/**/src (the fixture generator that produces
handle_regex.nr and its imports like zkregex::utils/select_subarray,
captures::capture_substring, sparse_array::SparseArray,
transitions::check_transition_with_captures) and re-run the generation step so
the corrected code is produced automatically.

In `@test/fixtures/linkHandleCommand/discord/src/main.nr`:
- Around line 1-37: This generated fixture (function main in the
test/fixtures/linkHandleCommand/*/src) was edited manually; revert any hand
changes and regenerate the file from the fixture generator instead of editing
directly. Locate the generated Noir file containing fn main(...) and restore it
by running the project’s fixture generation step (the generator that produces
test/fixtures/linkHandleCommand/*/src) so the file matches the canonical output;
if you need to change the behavior, update the generator that emits main rather
than editing this generated file.

In `@test/fixtures/linkHandleCommand/discord/src/sender_domain_regex.nr`:
- Around line 1-6: The file sender_domain_regex.nr is a generated fixture and
should not be edited directly; instead update the generator that produces files
under test/fixtures/linkHandleCommand/**/src so the import block (currently
referencing select_subarray, capture_substring, SparseArray,
check_transition_with_captures from zkregex::utils) is corrected there; modify
the generator code/template that emits sender_domain_regex.nr to change or
reorder those imports and then re-generate the fixtures so the repository
contains the updated generated artifact.

In `@test/fixtures/linkHandleCommand/discord/target/HonkVerifier.sol`:
- Around line 245-253: The exp(Fr base, Fr exponent) function currently only
repeatedly squares which yields base^(2^k) instead of base^exponent; replace it
with a square‑and‑multiply loop: unwrap the exponent to a uint (using
Fr.unwrap), initialize a result variable to Fr.wrap(1) and a working base
variable to base, then iterate while the exponent > 0—if (e & 1) multiply result
by working base, square the working base each iteration, and right‑shift the
exponent; finally return result (Fr) using Fr.wrap/unwrap as appropriate so
exp(base, exponent) computes base^exponent for any exponent bits.
- Around line 1837-1875: The batchMul function computes a cumulative "success"
flag across ecMul (precompile 7) and ecAdd (precompile 6) calls but never checks
it before returning, risking use of garbage results; update the assembly in
batchMul (function name: batchMul, local var: success) to revert on failure by
inserting an if iszero(success) { revert(0, 0) } check after the for loop
(mirroring the error handling used in invert and pow) so the function aborts
when any precompile call fails.

---

Nitpick comments:
In `@script/DeployLinkHandleEntrypoint/DeployLinkHandleEntrypointDiscord.s.sol`:
- Around line 12-15: The hardcoded Sepolia DKIM registry in
_getDkimRegistryAddress needs a chain guard: inside the function (or immediately
before returning) assert that block.chainid == 11155111 (Sepolia) and revert or
revert with a clear message if not, so the address cannot be used on other
chains; keep returning 0xc4f628496b8c474096650C8f9023954643cC614F when the chain
ID check passes and add a brief comment indicating this is Sepolia-only.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 275c9d2 and cd1ce01.

📒 Files selected for processing (8)
  • script/DeployLinkHandleEntrypoint/DeployLinkHandleEntrypointDiscord.s.sol
  • test/fixtures/linkHandleCommand/LinkHandleCommandTestFixture.sol
  • test/fixtures/linkHandleCommand/discord/Nargo.toml
  • test/fixtures/linkHandleCommand/discord/files/blueprint.json
  • test/fixtures/linkHandleCommand/discord/src/handle_regex.nr
  • test/fixtures/linkHandleCommand/discord/src/main.nr
  • test/fixtures/linkHandleCommand/discord/src/sender_domain_regex.nr
  • test/fixtures/linkHandleCommand/discord/target/HonkVerifier.sol

Comment thread test/fixtures/linkHandleCommand/discord/files/blueprint.json
Comment thread test/fixtures/linkHandleCommand/discord/Nargo.toml
Comment thread test/fixtures/linkHandleCommand/discord/src/handle_regex.nr
Comment thread test/fixtures/linkHandleCommand/discord/src/main.nr
Comment thread test/fixtures/linkHandleCommand/discord/src/sender_domain_regex.nr
Comment thread test/fixtures/linkHandleCommand/discord/target/HonkVerifier.sol
Comment thread test/fixtures/linkHandleCommand/discord/target/HonkVerifier.sol
@benceharomi
benceharomi merged commit 7f4df8c into main Mar 9, 2026
7 checks passed
@benceharomi
benceharomi deleted the discord branch March 9, 2026 16:07
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