示例#1
0
        public static byte[] CryptoNightV2(byte[] input, ICryptoNight cnParams)
        {
            /* CryptoNight Step 1: Use Keccak1600 to initialize the 'state'
             * buffer, encapsulated in cnState
             */
            CNState cnState = new CNState(Keccak.Keccak1600(input));

            byte[] scratchpad = CryptoNight.FillScratchpad(cnState, cnParams);

            MixScratchpadV2(cnState, cnParams, scratchpad);

            EncryptScratchpadToText(cnState, cnParams, scratchpad);

            return(CryptoNight.HashFinalState(cnState));
        }
示例#2
0
        public static byte[] CryptoNightV1(byte[] input, ICryptoNight cnParams)
        {
            if (input.Length < 43)
            {
                throw new ArgumentException(
                          "Input to CryptoNightV1 must be at least 43 bytes!"
                          );
            }

            /* CryptoNight Step 1: Use Keccak1600 to initialize the 'state'
             * buffer, encapsulated in cnState
             */
            CNState cnState = new CNState(Keccak.Keccak1600(input));

            byte[] scratchpad = CryptoNight.FillScratchpad(cnState, cnParams);

            byte[] tweak = CryptoNight.VariantOneInit(cnState, input);

            MixScratchpadV1(cnState, cnParams, scratchpad, tweak);

            EncryptScratchpadToText(cnState, cnParams, scratchpad);

            return(CryptoNight.HashFinalState(cnState));
        }