fix: twisted/Edwards conversion for circom compatibility#4
Merged
Conversation
Circom (circomlib) uses twisted Edwards form (a=168700) while arkworks uses standard Edwards form (a=1). Points flowing between circom and Rust need twisted_to_edwards()/edwards_to_twisted() conversion. - parse_decrypt_args: apply twisted_to_edwards() on ciphertext points from circom, with on-curve validation - msg_to_point: return twisted-form coordinates for circom consumption - Add network_pubkey_for_circom() helper for correct encryptedTo input - Bump version to 0.3.3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
parse_decrypt_args: Applytwisted_to_edwards()on ciphertext points received from circom, with on-curve validation assertionsmsg_to_point: Return twisted-form coordinates so circom receives the correct representationnetwork_pubkey_for_circom()(new): Helper returning the network pubkey as[x, y]decimal strings in twisted Edwards form for circom'sencryptedToinput0.3.3to trigger NPM publishContext
Circom (circomlib) uses twisted Edwards form (
a=168700, d=168696) while arkworksAffine<EdwardsConfig>uses standard Edwards form (a=1). The isomorphism scales x bysqrt(168700)— y stays the same. Without conversion, points from circom are off the Edwards curve, causing "Point not on curve" panics on.encode().See Slack thread for full debugging: https://holonymworkspace.slack.com/archives/C07A9MCSKG8/p1766056829885929
Test plan
cargo check -p human-network-sdkcompiles cleanlynetwork_pubkey_for_circom()returns correct twisted-form coords🤖 Generated with Claude Code