/// <inheritdoc />
        protected override byte[] SerializeImplementation()
        {
            var serialized       = new List <byte>();
            var parentMessageIds = ParentMessageIds.Select(id => id.HexToBytes()).ToList();
            var publicKeys       = PublicKeys.Select(key => key.HexToBytes()).ToList();
            var signatures       = Signatures.Select(signature => signature.HexToBytes()).ToList();

            serialized.AddRange(BitConverter.GetBytes(Type));
            serialized.AddRange(BitConverter.GetBytes(Index));
            serialized.AddRange(BitConverter.GetBytes(Timestamp));
            serialized.Add((byte)ParentMessageIds.Count);

            parentMessageIds.ForEach(serialized.AddRange);
            serialized.AddRange(InclusionMerkleProof.HexToBytes());
            serialized.AddRange(BitConverter.GetBytes(NextPoWScore));
            serialized.AddRange(BitConverter.GetBytes(NextPoWScoreMilestoneIndex));

            serialized.Add((byte)PublicKeys.Count);
            publicKeys.ForEach(serialized.AddRange);

            if (this.Receipt != null)
            {
                serialized.AddRange(this.Receipt.Serialize());
            }
            else
            {
                serialized.AddRange(BitConverter.GetBytes(0));
            }

            serialized.Add((byte)Signatures.Count);
            signatures.ForEach(serialized.AddRange);

            return(serialized.ToArray());
        }
 /* Makes a new view wallet with the given private+pub keys */
 private WalletBackend(string filename, string password,
                       PrivateKey privateViewKey,
                       PublicKeys publicKeys) : this(
         filename, password, null, privateViewKey, publicKeys.spendKey,
         publicKeys.viewKey, true
         )
 {
 }
Esempio n. 3
0
        private string Part1(PublicKeys keys)
        {
            var cardLoopSize      = FindSecretLoopSize(keys.Card, 7);
            var doorLoopSize      = FindSecretLoopSize(keys.Door, 7);
            var cardEncryptionKey = Transform(keys.Door, cardLoopSize);
            var doorEncryptionKey = Transform(keys.Card, doorLoopSize);

            return(cardEncryptionKey == doorEncryptionKey?cardEncryptionKey.ToString() : null);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructs an <see cref="ApplicationInfo"/> instance with the specified application
        /// name and public keys.
        /// </summary>
        ///
        /// <param name="name">
        /// The name of the application.
        /// </param>
        ///
        /// <param name="publicKeys">
        /// The public key(s) used to uniquely and positively identify the application to the
        /// HealthVault service. The application signs it's first request to HealthVault using it's
        /// application private which matches the public key being passed here. When HealthVault
        /// receives that request it validates the signature using the public key.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="publicKeys"/> is <b>null</b> or empty.
        /// If <paramref name="name"/> is <b>null</b> or empty.
        /// </exception>
        ///
        public ApplicationInfo(string name, IList <byte[]> publicKeys)
        {
            Validator.ThrowIfStringNullOrEmpty(name, "name");

            if (publicKeys == null || publicKeys.Count == 0)
            {
                throw new ArgumentException(Resources.ApplicationInfoPublicKeysRequired, nameof(publicKeys));
            }

            CultureSpecificNames.DefaultValue = name;

            PublicKeys.Clear();

            foreach (byte[] publicKey in publicKeys)
            {
                PublicKeys.Add(publicKey);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///     Get account name from address
        /// </summary>
        /// <param name="accounts">List of public account</param>
        /// <returns>IObservable&lt;List&lt;AccountNames&gt;&gt;</returns>
        public IObservable <List <AccountNames> > GetNamesFromAccount(List <PublicAccount> accounts)
        {
            if (accounts.Count < 0)
            {
                throw new ArgumentNullException(nameof(accounts));
            }

            var addresses = new PublicKeys
            {
                _PublicKeys = accounts.Select(a => a.PublicKey).ToList()
            };

            var route = $"{BasePath}/account/names";

            var networkType = GetNetworkTypeObservable().Take(1);

            return(Observable.FromAsync(async ar =>
                                        await route.PostJsonAsync(addresses).ReceiveJson <List <AccountNamesDTO> >())
                   .Select(i => i.Select(info => new AccountNames(info.Address, info.Names.ToList())).ToList()));
        }
Esempio n. 6
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var user          = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text
            };
            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                // Записываем ключи и модуль
                using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД
                {
                    RSA.RSA_Sign A_RSA_Sign = new RSA.RSA_Sign();            //конструктор
                    //String userId = (from x in new site_dbDataContext().AspNetUsers where x.Email == Context.User.Identity.Name select x.Id).First();
                    //Создаем объекты таблиц
                    PublicKeys PublicKey = new PublicKeys();
                    //PublicKey
                    PublicKey.PublicKey = A_RSA_Sign.E;
                    PublicKey.Mod       = A_RSA_Sign.N; //Mod
                    PublicKey.UserLogin = Email.Text;
                    contex.PublicKeys.InsertOnSubmit(PublicKey);
                    contex.SubmitChanges();
                    Sisurity PrivatKey = new Sisurity();
                    //PrivatKey
                    PrivatKey.PrivatKey = A_RSA_Sign.D;
                    PrivatKey.UserLogin = Email.Text;
                    contex.Sisurity.InsertOnSubmit(PrivatKey);
                    contex.SubmitChanges();
                }
                ///
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
Esempio n. 7
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
            var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
            IdentityResult result = manager.Create(user, Password.Text);
            if (result.Succeeded)
            {

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                // Записываем ключи и модуль
                using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД
                {
                    RSA.RSA_Sign A_RSA_Sign = new RSA.RSA_Sign(); //конструктор
                    //String userId = (from x in new site_dbDataContext().AspNetUsers where x.Email == Context.User.Identity.Name select x.Id).First();
                    //Создаем объекты таблиц
                    PublicKeys PublicKey = new PublicKeys();
                    //PublicKey
                    PublicKey.PublicKey = A_RSA_Sign.E;
                    PublicKey.Mod = A_RSA_Sign.N; //Mod
                    PublicKey.UserLogin = Email.Text;
                    contex.PublicKeys.InsertOnSubmit(PublicKey);
                    contex.SubmitChanges();
                    Sisurity PrivatKey = new Sisurity();
                    //PrivatKey
                    PrivatKey.PrivatKey = A_RSA_Sign.D;
                    PrivatKey.UserLogin = Email.Text;
                    contex.Sisurity.InsertOnSubmit(PrivatKey);
                    contex.SubmitChanges();
                }
                ///
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);

            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
    /// <summary>
    /// This method returns public keys of resource.
    /// </summary>
    /// <param name="jobDefinitionName">Job definition name.</param>
    /// <returns>Data transformation input.</returns>
    public PublicKeys GetPublicKeys()
    {
        var getResponse = _serviceHelper.GetPublicKeys(_resourceGroup, _resourceName);

        if (getResponse == null)
        {
            //throw new WebJobException("Job definition entity is being returned as null.");
        }

        JObject output = JObject.Parse(getResponse);
        string  dataServiceLevel1KeyString = output[Constants.Properties][Constants.DataServiceLevel1Key].ToString();
        var     dataServiceLevel1Key       = JsonConvert.DeserializeObject <DataServiceLevel1Key>(dataServiceLevel1KeyString);
        string  dataServiceLevel2KeyString = output[Constants.Properties][Constants.DataServiceLevel2Key].ToString();
        var     dataServiceLevel2Key       = JsonConvert.DeserializeObject <DataServiceLevel2Key>(dataServiceLevel2KeyString);
        var     publicKeys = new PublicKeys()
        {
            dataServiceLevel1Key = dataServiceLevel1Key,
            dataServiceLevel2Key = dataServiceLevel2Key
        };

        return(publicKeys);
    }