예제 #1
0
 public static byte[] CalculateSignature(ECPrivateKey signingKey, byte[] message)
 {
     if (signingKey.GetKeyType() == DJB_TYPE)
     {
         return(Curve25519.GetInstance(Curve25519ProviderType.BEST).CalculateSignature(((DjbECPrivateKey)signingKey).GetPrivateKey(), message));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.GetKeyType());
     }
 }
예제 #2
0
        public static byte[] CalculateAgreement(ECPublicKey publicKey, ECPrivateKey privateKey)
        {
            if (publicKey.GetKeyType() != privateKey.GetKeyType())
            {
                throw new InvalidKeyException("Public and private keys must be of the same type!");
            }

            if (publicKey.GetKeyType() == DJB_TYPE)
            {
                return(Curve25519.GetInstance(Curve25519ProviderType.BEST)
                       .CalculateAgreement(((DjbECPublicKey)publicKey).GetPublicKey(),
                                           ((DjbECPrivateKey)privateKey).GetPrivateKey()));
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + publicKey.GetKeyType());
            }
        }