Exemple #1
0
        public static byte[] calculateAgreement(ECPublicKey publicKey, ECPrivateKey privateKey)
        {
            if (publicKey == null)
            {
                throw new InvalidKeyException("public value is null");
            }

            if (privateKey == null)
            {
                throw new InvalidKeyException("private value is null");
            }

            if (publicKey.getType() != privateKey.getType())
            {
                throw new InvalidKeyException("Public and private keys must be of the same type!");
            }

            if (publicKey.getType() == DJB_TYPE)
            {
                return(Curve25519.getInstance(Curve25519ProviderType.BEST)
                       .calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
                                           ((DjbECPrivateKey)privateKey).getPrivateKey()));
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + publicKey.getType());
            }
        }
Exemple #2
0
 public static bool verifySignature(ECPublicKey signingKey, byte[] message, byte[] signature)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return(Curve25519.getInstance(Curve25519ProviderType.BEST)
                .verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Exemple #3
0
        public static byte[] verifyVrfSignature(ECPublicKey signingKey, byte[] message, byte[] signature)
        {
            if (signingKey == null || message == null || signature == null)
            {
                throw new InvalidKeyException("Values must not be null");
            }

            if (signingKey.getType() == DJB_TYPE)
            {
                return(Curve25519.getInstance(Curve25519ProviderType.BEST)
                       .verifyVrfSignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature));
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + signingKey.getType());
            }
        }
Exemple #4
0
 public static bool verifySignature(ECPublicKey signingKey, byte[] message, byte[] signature)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return Curve25519.getInstance(Curve25519ProviderType.BEST)
                          .verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature);
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Exemple #5
-1
        public static byte[] calculateAgreement(ECPublicKey publicKey, ECPrivateKey privateKey)
        {
            if (publicKey.getType() != privateKey.getType())
            {
                throw new InvalidKeyException("Public and private keys must be of the same type!");
            }

            if (publicKey.getType() == DJB_TYPE)
            {
                return Curve25519.getInstance(Curve25519ProviderType.BEST)
                                 .calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
                                                     ((DjbECPrivateKey)privateKey).getPrivateKey());
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + publicKey.getType());
            }
        }