コード例 #1
0
ファイル: Factory.cs プロジェクト: timburks2392/DigiByteMiner
        public IHashAlgorithm CreateAlgoObject(string name)
        {
            IHashAlgorithm algo = null;

            switch (name)
            {
            case "Skein":
                algo = new Skein.Skein();
                break;
            }
            return(algo);
        }
コード例 #2
0
        /* CryptoNight Step 5: Apply Keccak to the state again, and then
         * use the resulting data to select which of four finalizer
         * hash functions to apply to the data (Blake, Groestl, JH,
         * or Skein). Use this hash to squeeze the state array down
         * to the final 32 byte hash output.
         */
        private static byte[] HashFinalState(CNState cnState)
        {
            /* Get the state buffer as an array of ulongs rather than bytes */
            ulong[] hashState = cnState.GetHashState();

            Keccak.Keccak.keccakf(hashState, 24);

            /* Set the state buffer from the coerced hash state */
            cnState.SetHashState(hashState);

            /* Get the actual state buffer finally */
            byte[] state = cnState.GetState();

            IHashProvider p;

            /* Choose the final hashing function to use based on the value of
             * state[0] */
            switch (state[0] % 4)
            {
            case 0:
            {
                p = new Blake.Blake();
                return(p.Hash(state));
            }

            case 1:
            {
                p = new Groestl.Groestl();
                return(p.Hash(state));
            }

            case 2:
            {
                p = new JH.JH();
                return(p.Hash(state));
            }

            default:
            {
                p = new Skein.Skein();
                return(p.Hash(state));
            }
            }
        }