Beispiel #1
0
        public EdKeyPairGenerateResult GenerateKeyPair(EdDomainParameters domainParameters)
        {
            Sha = domainParameters.Hash;

            // Generate random number d
            var d = _entropyProvider.GetEntropy(1, NumberTheory.Pow2(domainParameters.CurveE.VariableB) - 1);

            // 1. Hash the private key
            // 2. Prune the buffer
            // Both accomplished by this function
            var h = HashPrivate(domainParameters, new BitString(d, domainParameters.CurveE.VariableB)).Buffer;

            // 3. Determine s
            var s = NumberTheory.Pow2(domainParameters.CurveE.VariableN) + h.ToPositiveBigInteger();

            // 4. Compute Q such that Q = s * G
            var Q = domainParameters.CurveE.Multiply(domainParameters.CurveE.BasePointG, s);

            // Encode Q
            var qEncoded = EdPointEncoder.Encode(Q, domainParameters.CurveE.VariableB);

            // Return key pair (Q, d)
            return new EdKeyPairGenerateResult(new EdKeyPair(qEncoded, new BitString(d, domainParameters.CurveE.VariableB)));
        }
Beispiel #2
0
 public BitString Encode(EdPoint point)
 {
     return(EdPointEncoder.Encode(point, VariableB));
 }