/// <summary> /// Generates a new address /// </summary> /// <param name="seed"></param> /// <param name="index"></param> /// <param name="checksum"></param> /// <param name="curl"></param> /// <returns></returns> internal static string NewAddress(string seed, int index, bool checksum, ICurl curl) { Signing signing = new Signing(curl); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime); int[] key = signing.Key(Converter.ToTrits(seed), index, 2); ts = stopWatch.Elapsed; elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime); int[] digests = signing.Digests(key); ts = stopWatch.Elapsed; elapsedTime = String.Format("After Digest {0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime); int[] addressTrits = signing.Address(digests); ts = stopWatch.Elapsed; elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime); string address = Converter.ToTrytes(addressTrits); if (checksum) { address = Checksum.AddChecksum(address); } return(address); }
/// <summary> /// Generates a new address /// </summary> /// <param name="seed">The tryte-encoded seed. It should be noted that this seed is not transferred.</param> /// <param name="security">The secuirty level of private key / seed.</param> /// <param name="index">The index to start search from. If the index is provided, the generation of the address is not deterministic.</param> /// <param name="checksum">The adds 9-tryte address checksum</param> /// <param name="curl">The curl instance.</param> /// <returns>An String with address.</returns> public static string NewAddress(string seed, int security, int index, bool checksum, ICurl curl) { if (security < 1) { throw new ArgumentException("invalid security level provided"); } Signing signing = new Signing(curl); int[] key = signing.Key(Converter.ToTrits(seed), index, security); int[] digests = signing.Digests(key); int[] addressTrits = signing.Address(digests); string address = Converter.ToTrytes(addressTrits); if (checksum) { address = Checksum.AddChecksum(address); } return(address); }
/// <summary> /// </summary> /// <param name="seed">Tryte-encoded seed. It should be noted that this seed is not transferred.</param> /// <param name="security">Secuirty level of private key / seed.</param> /// <param name="index"> /// Key index to start search from. If the index is provided, the generation of the address is not /// deterministic. /// </param> /// <returns>trytes</returns> public string GetDigest(string seed, int security, int index) { var key = _signing.Key(Converter.ToTrits(seed, 243), index, security); return(Converter.ToTrytes(_signing.Digests(key))); }