getInstance() public static method

Accesses the currently in use Curve25519 provider, according to the type requested.
public static getInstance ( Curve25519ProviderType type ) : Curve25519
type Curve25519ProviderType Type of provider requested.
return Curve25519
Esempio n. 1
0
        public static ECKeyPair generateKeyPair()
        {
            Curve25519KeyPair keyPair = Curve25519.getInstance(BEST).generateKeyPair();

            return(new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
                                 new DjbECPrivateKey(keyPair.getPrivateKey())));
        }
Esempio n. 2
0
 public static byte[] calculateSignature(ECPrivateKey signingKey, byte[] message)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return(Curve25519.getInstance(BEST)
                .calculateSignature(((DjbECPrivateKey)signingKey).getPrivateKey(), message));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Esempio n. 3
0
 public static bool verifySignature(ECPublicKey signingKey, byte[] message, byte[] signature)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return(Curve25519.getInstance(BEST)
                .verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Esempio n. 4
0
        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(BEST)
                       .calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
                                           ((DjbECPrivateKey)privateKey).getPrivateKey()));
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + publicKey.getType());
            }
        }
Esempio n. 5
0
 public static bool isNative()
 {
     return(Curve25519.getInstance(BEST).isNative());
 }
Esempio n. 6
0
 public static bool isNative()
 {
     return(Curve25519.getInstance(Curve25519ProviderType.BEST).isNative());
 }