Skip to content

Commit

Permalink
add grinding checks #84
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Nov 8, 2023
1 parent cbeb5e2 commit 55f4c2a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions contracts/zkllvm/circuit1/commitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ library modular_commitment_scheme_circuit1 {

bytes calldata proof_of_work = blob[blob.length - 4:];
transcript.update_transcript(tr_state, proof_of_work);
transcript.get_integral_challenge_be(tr_state, 4);

uint256 p_o_w = transcript.get_integral_challenge_be(tr_state, 4);
if (p_o_w & 4294901760 != 0) return false;


unchecked{
offset += 0x8 + r;
Expand Down Expand Up @@ -586,4 +587,4 @@ library modular_commitment_scheme_circuit1 {
return true;
}
}


2 changes: 1 addition & 1 deletion contracts/zkllvm/circuit2/commitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,4 @@ library modular_commitment_scheme_circuit2 {
return true;
}
}


5 changes: 3 additions & 2 deletions contracts/zkllvm/circuit3/commitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ library modular_commitment_scheme_circuit3 {

bytes calldata proof_of_work = blob[blob.length - 4:];
transcript.update_transcript(tr_state, proof_of_work);
transcript.get_integral_challenge_be(tr_state, 4);

uint256 p_o_w = transcript.get_integral_challenge_be(tr_state, 4);
if (p_o_w & 4294901760 != 0) return false;


unchecked{
offset += 0x8 + r;
Expand Down
5 changes: 3 additions & 2 deletions contracts/zkllvm/circuit4/commitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ library modular_commitment_scheme_circuit4 {

bytes calldata proof_of_work = blob[blob.length - 4:];
transcript.update_transcript(tr_state, proof_of_work);
transcript.get_integral_challenge_be(tr_state, 4);

uint256 p_o_w = transcript.get_integral_challenge_be(tr_state, 4);
if (p_o_w & 4294901760 != 0) return false;


unchecked{
offset += 0x8 + r;
Expand Down
5 changes: 3 additions & 2 deletions contracts/zkllvm/circuit6/commitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ library modular_commitment_scheme_circuit6 {

bytes calldata proof_of_work = blob[blob.length - 4:];
transcript.update_transcript(tr_state, proof_of_work);
transcript.get_integral_challenge_be(tr_state, 4);

uint256 p_o_w = transcript.get_integral_challenge_be(tr_state, 4);
if (p_o_w & 4294901760 != 0) return false;


unchecked{
offset += 0x8 + r;
Expand Down

0 comments on commit 55f4c2a

Please sign in to comment.