Пример #1
0
        public EncriptionResult EncryptEncodedNumber(ECCPoint encodedNumber, ECCPoint openKey)
        {
            var seancePrivateKey = GeneratePrivateKey(GeneratorPoint.PointDimention);

            var left  = ECCPoint.Multiply(seancePrivateKey, GeneratorPoint);          //tip for decryption
            var right = encodedNumber + ECCPoint.Multiply(seancePrivateKey, openKey); //encrypted point

            return(new EncriptionResult(left, right));
        }
Пример #2
0
        public ECCKey GenerateKey()
        {
            var key = new ECCKey();

            key.PrivateKey = GeneratePrivateKey(GeneratorPoint.PointDimention);
            key.OpenKey    = ECCPoint.Multiply(key.PrivateKey, GeneratorPoint);

            key.P = GeneratorPoint.Curve.FieldModule;
            key.G = GeneratorPoint;

            return(key);
        }
Пример #3
0
        public ECCPoint CreatePoint()
        {
            Random random = new Random();
            var    bytes  = new byte[64];

            random.NextBytes(bytes);

            var privateKey = new mpz_t(bytes, 0) % GeneratorPoint.PointDimention;

            if (privateKey < 0)
            {
                privateKey = privateKey * -1;
            }
            return(ECCPoint.Multiply(privateKey, GeneratorPoint));
        }