Skip to content

Commit

Permalink
chore: specify how counting zeros works in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Zk2u committed Sep 17, 2024
1 parent 4d91828 commit 7ae4c95
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ let salt = 0x616c70656e206c616273206661756365742032303234;
// nonce is the 16 decoded bytes from the API
// solution is a 8 byte array
// `|` is representing concatenation
count_leading_zeros(sha256(salt | nonce | solution)) >= difficulty
return count_leading_zeros(sha256(salt | nonce | solution)) >= difficulty;

fn count_leading_zeros(data: &[u8]) -> u8 {
let mut leading_zeros = 0;
for byte in data {
if *byte == 0 {
leading_zeros += 8;
} else {
leading_zeros += byte.leading_zeros() as u8;
break;
}
}

leading_zeros
}
```

Once you find a solution, hex encode it and use it in a claim for either L1 or L2 funds:
Expand Down

0 comments on commit 7ae4c95

Please sign in to comment.