Skip to content

Commit

Permalink
add ctr support for 2^32 blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
yash1io committed Aug 3, 2024
1 parent 34da47f commit 3de800c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions circuits/ctr.circom
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ template AddCipher(){
// converts iv to counter blocks
// iv is 16 bytes
template GenerateCounterBlocks(n){
assert(n < 0xffffffff);
signal input iv[16];
signal output counterBlocks[n][4][4];

Expand All @@ -131,6 +132,13 @@ template GenerateCounterBlocks(n){
ivr[15] = (ivr[15] + 1)%256;
if (ivr[15] == 0){
ivr[14] = (ivr[14] + 1)%256;
if (ivr[14] == 0){
ivr[13] = (ivr[13] + 1)%256;
if (ivr[13] == 0){
ivr[12] = (ivr[12] + 1)%256;
}
}
}

}
}

0 comments on commit 3de800c

Please sign in to comment.