Exemplo n.º 1
0
        public ByteString[] SignByteStrings(IUser[] users, params ByteString[] bs)
        {
            if (bs == null)
            {
                return(null);
            }

            if (bs.Length == 0)
            {
                return(null);
            }

            if (bs.Length == 1 && bs[0] == null)
            {
                return(null);
            }

            byte[] signbytes = new byte[bs.Sum(a => a.Length)];
            int    start     = 0;

            foreach (ByteString b in bs)
            {
                Array.Copy(b.ToByteArray(), 0, signbytes, start, b.Length);
                start += b.Length;
            }


            ByteString[] ret = new ByteString[users.Length];
            int          ii  = -1;

            foreach (IUser user in users)
            {
                // Get the signing identity from the user
                ISigningIdentity si = IdentityFactory.GetSigningIdentity(CryptoPrimitives, user);

                // generate signature
                ret[++ii] = ByteString.CopyFrom(si.Sign(signbytes));
            }

            return(ret);
        }
Exemplo n.º 2
0
        //private List<String> attrs;


        public TransactionContext(Channel channel, IUser user, ICryptoSuite cryptoPrimitives)
        {
            User    = user;
            Channel = channel;
            //TODO clean up when public classes are interfaces.
            Verify = !"".Equals(channel.Name); //if name is not blank not system channel and need verify.
            //  this.txID = transactionID;
            CryptoPrimitives = cryptoPrimitives;

            // Get the signing identity from the user
            signingIdentity = IdentityFactory.GetSigningIdentity(cryptoPrimitives, user);

            // Serialize signingIdentity
            Identity = signingIdentity.CreateSerializedIdentity();

            ByteString no = Nonce;

            byte[] comp = no.Concat(Identity.ToByteArray()).ToArray();
            byte[] txh  = cryptoPrimitives.Hash(comp);
            //    txID = Hex.encodeHexString(txh);
            TxID     = txh.ToHexString();
            toString = $"TransactionContext {{ txID: {TxID} mspid: {user.MspId}, user: {user.Name} }}";
        }