Skip to content

Commit 1123521

Browse files
committed
Final check of January MINA navigator report
1 parent 2f1a565 commit 1123521

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

navigator-reports/january-REPORT.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- The strict type assertion of o1js projects inhibited the usage of this powerful package regarding that it is written in vanilla JS.
1111
- It took time to add `.d.ts` file and fork the package to be strict TS-compatible.
1212
- The forked package is named [micro-bmark-ts](https://github.com/Shigoto-dev19/micro-bmark-ts) which can be useful now for other developers as well.
13-
- Add script for swift usage of the benchmark file -> `npm run benchmark`
13+
- Add script for swift usage of the benchmark file -> `npm run benchmark`.
1414
- The difference between `command.ts` and `benchmark.ts` files
1515
- I use the command file for print debugging and having a rough idea on performance.
1616
- The benchmark files serves to compare the performance of difference function based on the number of iteration and optional stat logs.
@@ -27,8 +27,8 @@
2727
- Now the `sha256` is faster
2828
- Add logs to track performance of both poseidon and sha256 circuits
2929
- log wires and gates number
30-
- it seems to be different that vkregression
31-
- TODO: further research for the exact gate number of a MINA circuit<
30+
- it seems to be different than vkregression
31+
- TODO: further research for the exact gate number of a MINA circuit.
3232
- log key generation, proving, and verification time.
3333
- Timer Class required:
3434
- Move to test-utils.ts file
@@ -39,16 +39,16 @@
3939

4040
- Add the optimized version to commands.ts
4141
- A version of o1js SHA256 hash function optimized fully with native o1js gadgets is `10 times` faster that a hash function simulated to the implementation in circom!! -> command.ts log -> 1 iteration.
42-
- SHA256 Benchmarks -> also verified by the benchmark script -> 1000 iterations
43-
├─o1js x 46 ops/sec @ 21ms/op
44-
├─o1jsOP x 388 ops/sec @ 2ms/op
42+
- SHA256 Benchmarks -> also verified by the benchmark script -> 1000 iterations.
43+
- ├─o1js x 46 ops/sec @ 21ms/op.
44+
- ├─o1jsOP x 388 ops/sec @ 2ms/op
4545
- The first SHA256 hash function was a combination of native o1js gadgets and simulated circom templated for other bitwise function
4646
- After the last release, the 32-bit bitwise functions are now available.
4747
- Adding the SHA256 function using purely the bitwise functions from the gadgets, it seems that it is worth comparing to the first hash function
4848
- Write `ch` and `maj` bitwise function similar to the sha256 circom circuit implementation.
4949
- Realize that `shift32` bitwise function was not correct after assertions -> Fix error source
5050
- The latest release included leftShift32 and not rightShift and a simulated implementation was incorrect because leftShift is based on multiplication and rightShift on division
51-
- division of field element give non-compliant results
51+
- division of field element returns non-compliant results
5252
- the solution is to use `Gadgets.rotate64(field, bits, 'right')` function to shift the bits to the left i.e getting rid of them and then truncate the rotated bits using Gadgets.divMod32() function.
5353
```typescript
5454
let { remainder: shifted } = Gadgets.divMod32(
@@ -63,7 +63,7 @@
6363

6464
### DAY4: 13th January
6565

66-
- Move TWO32 constant from function to the `constants.ts`
66+
- Move TWO32 constant from function to the `constants.ts`.
6767
- Now that the o1js sha256 is validated as more efficient than the circom implementation, the following changes are made:
6868
- Create a new directory called `benchmarks`
6969
- This directory contains the benchmarks code --> `benchmark.ts`
@@ -81,7 +81,7 @@
8181
- Polish test-utils imports to reduce import redundancy(mainly from node crypto library)
8282
- Move all export objects from bottom to the top of files(all) for better readability.
8383
- **Note:** after separation, preprocessing function using native o1js bitwise gadgets are used in common for the native and circom implementation but it doesn't have effect on the performance because it is only called once
84-
- this is verified by comparing old and new benchmark after restructuring of the project
84+
- this is verified by comparing the old and new benchmarks after the restructuring of the project
8585
- Resturcturing and polishing the code took time and became a huge commit
8686
- Improve readability and code quality --> the project will still get bigger
8787
- This is crucial to separate operational code from other utility code
@@ -94,17 +94,17 @@
9494
- Move `command.ts` to the benchmarks directory and adapt code.
9595
- Add sha3-256 to the benchmarks --> result is it has the same performance as sha256 function which is good news
9696
- for 2500 iterations, sha3 is slightly better in performance but that might because of the noise of input handling in sha256.
97-
-note: the o1js sha3 input is limited to 32 bytes
97+
- Note: the o1js sha3 input is limited to 32 bytes
9898
- Add witness benchmarks for poseidon, sha3_256 and sha256 in a new file called `sha256-witness.ts`
9999
- Add script ==> `npm run witness-time`
100100
- Regarding that SHA256 will be used in most cases for using field i.e number instead of string in a circuit
101101
- the input handling was quite different with o1js than other js/ts sha256 hash function, most of the function use **Uint8Array** as input if the input was desired to be a number.
102102
- I was aiming to hash a field directly to simulate poseidon function inputs in o1js
103103
- I adapted code to be compliant
104-
- this was cumbersome, this step is always exhausting regarding that the avalance effect of the hash function always makes it difficult to track error source
104+
- This was cumbersome, this step is always exhausting regarding that the avalanche effect of the hash function always makes it difficult to track error source
105105
- Add test cases for hashing inputs as field or Uint8Array
106-
- tests pass but the hash function throws an error about pointing that the code is not provable when compiled
107-
- send time debugging but might use input handling of Uint8Array similar to what's released in o1js SHA3_256
106+
- Tests pass but the hash function throws an error about pointing that the code is not provable when compiled
107+
- Spend time debugging but might use input handling of Uint8Array similar to what's released in o1js SHA3_256
108108

109109
### DAY6: 17th January
110110

@@ -119,8 +119,8 @@
119119
- Update test-util random input generator for both strings and Uint8array type
120120
- Omit redundant code that separated between string and Field input types
121121
- Update tests and verify integrity
122-
- check that project code is functional, provable, and deployable.
123-
- constraint logs are showing an error, maybe the Circuit API is not yet updated to the Bytes provable type
122+
- Check that project code is functional, provable, and deployable.
123+
- Constraint logs are showing an error, maybe the Circuit API is not yet updated to the Bytes provable type.
124124
- After a lot of debugging --> all other scripts work
125125
- Deployable main.ts
126126
- ProofsEnable Deployable main.ts
@@ -133,7 +133,7 @@
133133
- Use `bytesToWord` and `wordToBytes` functions using code imported from `./o1js/src/lib/gadgets/bit-slices.ts`.
134134
- Set the main o1js sha256 output to bytes to be compliant with the o1js sha3 release.
135135
- Change index.ts to handle bytes output as a poseidon digest => enables single field assertion.
136-
- Adapt zkcontract and main.ts code for successfull deployment
136+
- Adapt zkcontract and main.ts code for successfull deployment.
137137
- All tests pass but benchmarks show that the sha256 is two times slower than before which raises a big question for me.
138138
- The constrainSystem file for sha256 is still not running, which still gives me supspicions about Bytes32 compatibility with the o1js Circuit API.
139139
- Learn more about o1js advanced types and realize that `Provable.array(ProvableType, num)` solves the issue I pointed to yesterday about array non-compliance with `Provable.witness`
@@ -148,9 +148,9 @@
148148
- Sort order of preprocessing functions.
149149
- Update all bitwise functions to use UInt32 type instead of Field for better size assertion.
150150
- Convert all 32 bit words from implicit Field to UInt32 type.
151-
- Utilize native bitwise function such as rotate and rightShift directly from UInt32 methods.
151+
- Utilize native bitwise functions such as rotate and rightShift directly from UInt32 methods.
152152
- Remove redundant bitwise function declarations.
153-
- Update sha256 circom implementation regarding that it imports functions commonly from **preprocessing.ts**
153+
- Update sha256 circom implementation regarding that it imports functions commonly from **preprocessing.ts**.
154154
- Fix addMod32 to not use UInt32 because addition in UIn32 doesn't overflow.
155155
- Bechmarks show that sha256 is 60% faster than the one from the last commit.
156156
- It is amazing how the o1js added many useful perks in the last release.
@@ -159,7 +159,7 @@
159159
### DAY9: 22th January
160160

161161
- Integrate logs in test utility Timer class.
162-
- Now it accepts an optional title in the constructor and logs it with executionTime when end() method is called
162+
- Now it accepts an optional title in the constructor and logs it with executionTime when `end()` method is called
163163
- I wonder if there is a direct method like `assertEquals` for the provable Bytes class.
164164
- Add SHA256 ZkProgram instance
165165
- It includes logs for compile, proving, and verification time
@@ -174,7 +174,7 @@
174174
- In order to use the SHA256 as updatable hash function --> Add update method
175175
- Add SHA256 class that is restructuring of the single function into a class to enable adding update method.
176176
- update method is a chained method that returns an instance of the SHA256 class.
177-
- in other words, when hashing a single input, we initialize the function with nothing-up my sleeve words; on the otherside the update method set the digest word as the initial state for a new input.
177+
- in other words, when hashing a single input, we initialize the function with nothing-up my sleeve words; on the otherside the update method set the digest words as the initial state for a new input.
178178
- It was difficult to have the gist of how things work with chained instances of class to have a running update method.
179179
- The update method when used as `let digest = new SHA256().update(input).digest()` works fine with a single input.
180180
- The update method method doesn't output expected digest results when trying to chain different scattered bytes

0 commit comments

Comments
 (0)