Check out the Issue Explorer
Looking to fund some work? You can submit a new Funded Issue here.
- Intel accelerated crypto instructions define sha256 extension instructions - they have not been widely implemented on the last few generations of Intel CPUs
- AMD ships both server and desktop CPUs with the `sha extension instructions` (EPYC and RYZEN)
- Servers with EPYC cpus are now available on [AWS](https://aws.amazon.com/about-aws/whats-new/2018/11/introducing_amazon_ec2_instances_featuring_amd_epyc_processors/), and are good candidates for running Spacemesh production POET for our MVP1 testnet milestone
- [Some benchmarks](https://bench.cr.yp.to/impl-hash/sha256.html) show ~x3-x5 pref over sha256 software implementations
- There are already several open source libraries that use the SHA instructions to compute SHA256 for a small input buffer
1. Your dev box CPU is `AMD RYZEN` or `AMD EPYC` and it supports the sha256 instructions ( `cpuid=sha256`)
2. You have knowledge of how to use assembly code sections in a go project. See https://blog.sgmansfield.com/2017/04/a-foray-into-go-assembly-programming/
3. You are familiar with the concept of crypto hashes
4. You are an intermediate or experienced go developer
# The Task
1. Implement and test sha256() using Intel sha256 instructions using assembly code published by open source libraries. Please try to use assembly directly from GO without resorting to C code. Your implemented type should implement the [hash.Hash interface](https://golang.org/pkg/hash/#Hash)
2. The hardware optimized sha256 function should be automatically used when the cpu support SHA (`cpuid=SHA`) instead of the current sha256 function
3. You must write tests showing 100% binary compatibility of your implemented function with the existing sha256() function on a variety of hard-coded test vectors and random binary data. These tests must pass for this task to be complete
4. Your solution must be as performant as possible. You may start by following the solution outlined here: https://github.com/randombit/botan/commit/039b7141889b4bdca88f18cd65a6d897f8c80848 but further optimizations may be possible
5. Update the POET code to test for `cpuid=sha256` on app startup and use the new sha256 you wrote instead of the old one in this case. e.g. Your optimized hasher should be a drop-in replacement to the currently used one on supported systems
6. Write some simple go benchmarks to compare your new sha256 function with the one currently used in the project (AVX2 instruction set optimized)
7. Submit a PR for review in this repo when your code is ready for review and testing by our team!
# Contest Terms
- We are going to accept the first 3 developers who are interested to participate in this contest that introduce themselves on our [Gitter dev talk channel](https://gitter.im/spacemesh-os/POET)
- Each correct submission from the 3 accepted developers which passes the binary compatibility test will be tipped using a Gitcoin tip of 5 Eth
- If a developer doesn't submit code in 2 weeks then we may accept other developers instead of him or her.
- The fastest correct submission is going to be awarded additional 5 eth, a special custom Spacemesh honorary badge and some additional schwag
- Good luck!
## Additional resources
- OpenSSL intel SHA instruction set optimizations https://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=CHANGES - OpenSSL sha256() should be hardware accelerated already for ZEN arch (cpuid=sha, sha256)
## Contest Terms
By participating in the contest, you agree to these terms and conditions.
This contest is an experimental and discretionary rewards program to encourage and reward those who are helping to improve the platform. You should know that we can cancel or amend the terms of the program at any time, and we have the sole discretion to determine whether or not the criteria to qualifications for compensation hereunder, as described in the contest terms, are met in a satisfactory manner. When compensated in Ethereum cryptocoins, the amount will be determined according to the $ value of the cryptocoin on the date of payment.
We are unable to issue rewards to individuals who are on any US or Israeli sanctions lists, or who are in countries on any US or Israeli sanctions lists.
You are responsible for any tax implications depending on your country of residency and citizenship. There may be additional restrictions on your ability to receive the award depending upon your local law.
Your participation in the contest must not violate any law, or disrupt, compromise or make unauthorized use of any data or know-how that is not your own.
By participating in the program, you hereby: (i) represent that you are aware that the Spacemesh open source project is an MIT licensed free open source software and that your contribution is consistent with this fact, and (ii) grant us, our subsidiaries, affiliates and customers a non-exclusive, perpetual, irrevocable, worldwide, royalty-free, transferable, sub licensable (through multiple tiers) license to use, reproduce, adapt, modify, publish, distribute, publicly perform, create derivative work from, make, use, sell, offer for sale and import for any purpose any materials submitted by you in connection with any task performed in the framework of the contest.