Skip to content
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

Fix shift malleability attack. #124

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Fix shift malleability attack. #124

merged 1 commit into from
Oct 26, 2023

Conversation

SoraSuegami
Copy link
Collaborator

@SoraSuegami SoraSuegami commented Oct 25, 2023

As pointed out in zkp2p/zk-p2p#113, the current VarShiftLeft template does not check that the given shift is at the first position of the non-masked string.
It allows an adversary to extract an arbitrary substring of the non-masked string.

I added VarShiftMaskedStr and ShiftAndPackMaskedStr in packages/circuits/helpers/extract.circom to fix that issue in the following approach.

  1. The circuit takes as input the starting index shift.
  2. The shift template constrains the following conditions.
  • in[shift] is not zero.
  • shift is zero or in[shift-1] is zero.

@socket-security
Copy link

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@zk-email/zk-regex-circom 1.1.0...1.1.1 None +0/-0 197 kB sora_suegami

@SoraSuegami SoraSuegami merged commit 8a37dba into main Oct 26, 2023
5 checks passed
@saleel saleel deleted the var_shift_fix branch April 19, 2024 04:29
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.

1 participant