UPDATED: streamlined scrypt implementation (merged from litecoin)