Пример #1
0
 public Messenger(string arg, byte[] privateKey)
 {
     blockchain = new Blockchain("/blockchain");
     userName   = arg;
     if (privateKey.Length != 32)
     {
         throw new System.ArgumentException("wrong key length, must be 32 symbols");
     }
     EllipticCurve = Rebex.Security.Cryptography.Curve25519.Create(Rebex.Security.Cryptography.Curve25519.Curve25519Sha256);
     EllipticCurve.FromPrivateKey(privateKey);
 }
Пример #2
0
        public Messenger(string arg)
        {
            blockchain = new Blockchain("/blockchain");
            byte[] privateKey = new byte[32];
            System.Security.Cryptography.RandomNumberGenerator rng = System.Security.Cryptography.RandomNumberGenerator.Create();
            rng.GetBytes(privateKey);

            userName      = arg;
            EllipticCurve = Rebex.Security.Cryptography.Curve25519.Create(Rebex.Security.Cryptography.Curve25519.Curve25519Sha256);
            EllipticCurve.FromPrivateKey(privateKey);
        }
Пример #3
0
 public Messenger(string arg, string privateKey)
 {
     blockchain = new Blockchain("/blockchain");
     userName   = arg;
     privateKey = privateKey.ToLower();
     if (privateKey.Length != 64)
     {
         throw new System.ArgumentException("wrong hex key length, must be 64 symbols");
     }
     for (int i = 0; i < privateKey.Length; i++)
     {
         if (!((privateKey[i] >= '0' && privateKey[i] <= '9') || (privateKey[i] >= 'a' && privateKey[i] <= 'f')))
         {
             throw new System.ArgumentException("wrong hex key symbols");
         }
     }
     EllipticCurve = Rebex.Security.Cryptography.Curve25519.Create(Rebex.Security.Cryptography.Curve25519.Curve25519Sha256);
     EllipticCurve.FromPrivateKey(System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary.Parse(privateKey).Value);
 }