コード例 #1
0
ファイル: CCMC.cs プロジェクト: neo-ngd/n3-asset
        public static bool verifySigWithOrderForHashTest(byte[] rawHeader, byte[] signList)
        {
            ECPoint[] keepers = (ECPoint[])StdLib.Deserialize(Storage.Get(Storage.CurrentContext, mCKeeperPubKeysPrefix));
            notify("Keepers: " + keepers.Length);
            ByteString message  = (ByteString)Hash256(rawHeader);
            int        m        = signList.Length / MCCHAIN_SIGNATURE_LEN;
            int        n        = keepers.Length;
            bool       fSuccess = true;

            for (int i = 0, j = 0; fSuccess && i < m && j < n;)
            {
                ByteString signedMessage = (ByteString)signList.Range(i * MCCHAIN_SIGNATURE_LEN, MCCHAIN_SIGNATUREWITHOUTV_LEN);
                try
                {
                    if (CryptoLib.VerifyWithECDsa(message, keepers[j], signedMessage, NamedCurve.secp256k1))
                    {
                        i++;
                    }
                    j++;
                    if (m - i > n - j)
                    {
                        fSuccess = false;
                    }
                }
                catch
                {
                    notify("verifySig exception");
                }
                finally
                {
                    notify("Number: " + m + i + n + j);
                }
            }
            return(fSuccess);
        }
コード例 #2
0
ファイル: CCMC.cs プロジェクト: neo-ngd/n3-asset
        /// <summary>
        /// Tested, 校验rawHeader的签名是否满足条件
        /// </summary>
        /// <param name="rawHeader"></param>
        /// <param name="signList"></param>
        /// <param name="keepers"></param>
        /// <returns></returns>
        public static bool verifySigWithOrder(byte[] rawHeader, byte[] signList, ECPoint[] keepers)
        {
            ByteString message  = (ByteString)Hash256(rawHeader);
            int        m        = signList.Length / MCCHAIN_SIGNATURE_LEN;
            int        n        = keepers.Length;
            bool       fSuccess = true;

            for (int i = 0, j = 0; fSuccess && i < m && j < n;)
            {
                ByteString signedMessage = (ByteString)signList.Range(i * MCCHAIN_SIGNATURE_LEN, MCCHAIN_SIGNATUREWITHOUTV_LEN);
                try
                {
                    if (CryptoLib.VerifyWithECDsa(message, keepers[j], signedMessage, NamedCurve.secp256k1))
                    {
                        i++;
                    }
                    j++;
                    if (m - i > n - j)
                    {
                        fSuccess = false;
                    }
                }
                catch
                {
                    notify("verifySig exception");
                }
            }
            return(fSuccess);
        }
コード例 #3
0
 public static bool Secp256k1VerifySignatureWithMessage(byte[] message, ECPoint pubkey, byte[] signature)
 {
     return(CryptoLib.VerifyWithECDsa((ByteString)message, pubkey, (ByteString)signature, NamedCurve.secp256k1));
 }