Beispiel #1
0
        public static bool VerifySignature(scriptSig scriptSig, string strOpScript, string strOriginalTxt)
        {
            // string strDecodeTxt = rsaPubDecrySign(strSignature, strPubKey, false);
            // return string.Equals(strDecodeTxt, strOriginalTxt);
            string strDecodeTxt = string.Empty;

            Operation Oper = new Operation(scriptSig, strOpScript);
            bool      bRet = Oper.RunScript(ref strDecodeTxt);

            if (bRet)
            {
                if (string.Equals(strDecodeTxt, strOriginalTxt))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 public void addSignature(scriptSig Sig)
 {
     if (this.ScriptSig == null)
     {
         ScriptSig = new scriptSig();
     }
     this.ScriptSig = Sig;
 }
Beispiel #3
0
        public void MultiSignTrans(string strmyPriKeyPath, string strmyPubkeyValue, int InputIndex)
        {
            string    strRawdata    = this.getRawDataToSign(InputIndex);
            scriptSig tempScriptSig = new scriptSig();

            tempScriptSig.Signature = Cryptor.rsaPriSign(strRawdata, strmyPriKeyPath);
            tempScriptSig.PubKey    = strmyPubkeyValue;
            listInputs[InputIndex].addMutiSignTolst(tempScriptSig);
        }
Beispiel #4
0
        public Operation(scriptSig inputSig, string outputScript)
        {
            this.staData = new Stack <string>();
            this.AddData(inputSig.Signature);
            this.AddData(inputSig.PubKey);

            this.lstPubOperate = new List <string>();
            this.lstPubOperate = this.PubScri2list(outputScript);
        }
Beispiel #5
0
 public void addMutiSignTolst(scriptSig Sig)
 {
     if (this.lstScriptSig == null)
     {
         this.lstScriptSig = new List <scriptSig>();
     }
     if (!this.lstScriptSig.Contains(Sig))
     {
         this.lstScriptSig.Add(Sig);
     }
 }
Beispiel #6
0
        public void signTrans(string strmyPriKeyPath, string strmyPubkeyValue, int InputIndex)
        {
            string    strRawdata    = this.getRawDataToSign(InputIndex);
            scriptSig tempScriptSig = new scriptSig();

            tempScriptSig.Signature = Cryptor.rsaPriSign(strRawdata, strmyPriKeyPath);
            tempScriptSig.PubKey    = strmyPubkeyValue;

            // modified by fdp 190110
            listInputs[InputIndex].addSignature(tempScriptSig);
            //listInputs[InputIndex].ScriptSig.Signature = Cryptor.rsaPriSign(strRawdata, strmyPriKeyPath);
            //listInputs[InputIndex].ScriptSig.PubKey = strmyPubkeyValue;
        }
Beispiel #7
0
        public Input(string strHash, int index)
        {
            if (string.IsNullOrEmpty(strHash))
            {
                PreTxHash = string.Empty;
            }
            else
            {
                PreTxHash = strHash;
            }
            OutputIndex = index;

            ScriptSig = new scriptSig();
        }
Beispiel #8
0
        public override bool Equals(Object other)
        {
            if (other == null)
            {
                return(false);
            }
            scriptSig otherSc = (scriptSig)other;

            // 直接对比hash是否一致
            if (this.GetHashCode() != otherSc.GetHashCode())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #9
0
        public Transaction CreatCoinBaseTX(string strAddress)
        {
            Transaction basecoinTrans   = new Transaction();
            string      basecoinPrehash = "0000000000000000000000000000000000000000000000000000000000000000";
            int         basecoinIndex   = -1;
            Input       basecoinInput   = new Input(basecoinPrehash, basecoinIndex);
            scriptSig   bassecoinSS     = new scriptSig();
            string      nowTime         = DateTime.Now.ToString("yyyyMMddHHmmssfff");

            bassecoinSS.Signature = Cryptor.SHA256(nowTime, nowTime.Length);
            bassecoinSS.PubKey    = Cryptor.SHA256(bassecoinSS.Signature, bassecoinSS.Signature.Length);
            basecoinInput.addSignature(bassecoinSS);
            basecoinTrans.addInput(basecoinInput);

            basecoinTrans.addOutput(24, strAddress);
            basecoinTrans.FinalSetTrans();
            return(basecoinTrans);
            //this.poolTx.Add(RewardTrans);
        }
Beispiel #10
0
 public void addSignature(scriptSig signature, int index)
 {
     listInputs[index].addSignature(signature);
 }
Beispiel #11
0
 public void addSignature(scriptSig Sig)
 {
     this.ScriptSig = Sig;
 }