Skip to content

Commit

Permalink
Add range check to each input byte
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Oct 9, 2024
1 parent 69d57b9 commit 94bc3cf
Show file tree
Hide file tree
Showing 37 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/circom/circuits/common/body_hash_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template BodyHashRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/email_addr_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template EmailAddrRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/email_domain_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template EmailDomainRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/from_all_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template FromAllRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/message_id_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template MessageIdRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template ReversedBracketRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/subject_all_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template SubjectAllRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/timestamp_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template TimestampRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/circuits/common/to_all_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template ToAllRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/asterisk1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Asterisk1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/asterisk2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Asterisk2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/asterisk3_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Asterisk3Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/caret1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Caret1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/caret2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Caret2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/caret3_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Caret3Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/caret4_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Caret4Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/caret5_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Caret5Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/dollar1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Dollar1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/dollar2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Dollar2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/dot1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Dot1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/dot2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Dot2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template InternationalCharsDecomposed(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/negate1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Negate1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/negate2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Negate2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/plus1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Plus1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/plus2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Plus2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/plus3_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Plus3Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/plus4_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Plus4Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/question1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Question1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/question2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Question2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/question3_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template Question3Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/reveal_check1_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template RevealCheck1Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/reveal_check2_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template RevealCheck2Regex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/circom/tests/circuits/simple_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template SimpleRegex(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template SimpleRegexDecomposed(msg_bytes) {
signal in[num_bytes];
in[0]<==255;
for (var i = 0; i < msg_bytes; i++) {
_ <== LessThan(8)([msg[i], 255]);
in[i+1] <== msg[i];
}

Expand Down
1 change: 1 addition & 0 deletions packages/compiler/src/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ fn generate_declarations(
"\tsignal in[num_bytes];".to_string(),
"\tin[0]<==255;".to_string(),
"\tfor (var i = 0; i < msg_bytes; i++) {".to_string(),
"\t\t_ <== LessThan(8)([msg[i], 255]);".to_string(),
"\t\tin[i+1] <== msg[i];".to_string(),
"\t}".to_string(),
"".to_string(),
Expand Down

0 comments on commit 94bc3cf

Please sign in to comment.