Ejemplo n.º 1
0
        public SignedBid(Bid bid, Signature sig, MultisigSignature mSig)
        {
            this.bid = JavaHelper <Bid> .RequireNotNull(bid, "tx must not be null");

            this.mSig = JavaHelper <MultisigSignature> .RequireNotNull(mSig, "mSig must not be null");

            this.sig = JavaHelper <Signature> .RequireNotNull(sig, "sig must not be null");
        }
Ejemplo n.º 2
0
 public SignedBid([JsonProperty(PropertyName = "bid")] Bid bid,
                  [JsonProperty(PropertyName = "sig")] byte[] sig,
                  [JsonProperty(PropertyName = "msig")] MultisigSignature mSig)
 {
     if (bid != null)
     {
         this.bid = bid;
     }
     if (sig != null)
     {
         this.sig = new Signature(sig);
     }
     if (mSig != null)
     {
         this.mSig = mSig;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// SignMultisigTransaction creates a multisig transaction from the input and the multisig account.
        /// </summary>
        /// <param name="from">sign as this multisignature account</param>
        /// <param name="tx">the transaction to sign</param>
        /// <returns>SignedTransaction a partially signed multisig transaction</returns>
        public SignedTransaction SignMultisigTransaction(MultisigAddress from, Transaction tx) //throws NoSuchAlgorithmException
        {
            // check that from addr of tx matches multisig preimage
            if (!tx.sender.ToString().Equals(from.ToString()))
            {
                throw new ArgumentException("Transaction sender does not match multisig account");
            }
            // check that account secret key is in multisig pk list
            var myPK = this.GetEd25519PublicKey();

            byte[] myEncoded = myPK.GetEncoded();
            int    myI       = -1;

            for (int i = 0; i < from.publicKeys.Count; i++)
            {
                if (Enumerable.SequenceEqual(myEncoded, from.publicKeys[i].GetEncoded()))
                {
                    myI = i;
                    break;
                }
            }

            if (myI == -1)
            {
                throw new ArgumentException("Multisig account does not contain this secret key");
            }
            // now, create the multisignature
            SignedTransaction txSig = this.SignTransaction(tx);
            MultisigSignature mSig  = new MultisigSignature(from.version, from.threshold);

            for (int i = 0; i < from.publicKeys.Count; i++)
            {
                if (i == myI)
                {
                    mSig.subsigs.Add(new MultisigSubsig(myPK, txSig.sig));
                }
                else
                {
                    mSig.subsigs.Add(new MultisigSubsig(from.publicKeys[i]));
                }
            }
            return(new SignedTransaction(tx, mSig, txSig.transactionID));
        }
Ejemplo n.º 4
0
        public LogicsigSignature(
            [JsonProperty("l")] byte[] logic,
            [JsonProperty("arg")] List <byte[]> args      = null,
            [JsonProperty("sig")] byte[] sig              = null,
            [JsonProperty("msig")] MultisigSignature msig = null)
        {
            this.logic = JavaHelper <byte[]> .RequireNotNull(logic, "program must not be null");

            this.args = args;

            if (!Logic.CheckProgram(this.logic, this.args))
            {
                throw new Exception("program verified failed!");
            }

            if (sig != null)
            {
                this.sig = new Signature(sig);
            }
            this.msig = msig;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sign LogicSig as multisig
        /// </summary>
        /// <param name="lsig">LogicsigSignature to sign</param>
        /// <param name="ma">MultisigAddress to format multi signature from</param>
        /// <returns>LogicsigSignature</returns>
        public LogicsigSignature SignLogicsig(LogicsigSignature lsig, MultisigAddress ma)
        {
            var pk      = this.GetEd25519PublicKey();
            int pkIndex = -1;

            for (int i = 0; i < ma.publicKeys.Count; i++)
            {
                if (Enumerable.SequenceEqual(pk.GetEncoded(), ma.publicKeys[i].GetEncoded()))
                {
                    pkIndex = i;
                    break;
                }
            }

            if (pkIndex == -1)
            {
                throw new ArgumentException("Multisig account does not contain this secret key");
            }
            // now, create the multisignature
            byte[]            bytesToSign = lsig.BytesToSign();
            Signature         sig         = this.RawSignBytes(bytesToSign);
            MultisigSignature mSig        = new MultisigSignature(ma.version, ma.threshold);

            for (int i = 0; i < ma.publicKeys.Count; i++)
            {
                if (i == pkIndex)
                {
                    mSig.subsigs.Add(new MultisigSubsig(pk, sig));
                }
                else
                {
                    mSig.subsigs.Add(new MultisigSubsig(ma.publicKeys[i]));
                }
            }
            lsig.msig = mSig;
            return(lsig);
        }
Ejemplo n.º 6
0
 public SignedBid(Bid bid, MultisigSignature mSig) : this(bid, new Signature(), mSig)
 {
 }