Search in sources :

Example 11 with Ed25519GroupElement

use of io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519GroupElement in project nem2-sdk-java by nemtech.

the class Ed25519KeyGeneratorTest method derivedPublicKeyIsValidPointOnCurve.

@Test
public void derivedPublicKeyIsValidPointOnCurve() {
    // Arrange:
    final KeyGenerator generator = this.getKeyGenerator();
    for (int i = 0; i < 100; i++) {
        final KeyPair kp = generator.generateKeyPair();
        // Act:
        final PublicKey publicKey = generator.derivePublicKey(kp.getPrivateKey());
        // Assert (throws if not on the curve):
        Ed25519GroupElement decode = new Ed25519EncodedGroupElement(publicKey.getBytes()).decode();
        Assertions.assertNotNull(decode);
    }
}
Also used : KeyPair(io.nem.symbol.core.crypto.KeyPair) PublicKey(io.nem.symbol.core.crypto.PublicKey) Ed25519GroupElement(io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519GroupElement) KeyGenerator(io.nem.symbol.core.crypto.KeyGenerator) Ed25519EncodedGroupElement(io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement) Test(org.junit.jupiter.api.Test) KeyGeneratorTest(io.nem.symbol.core.crypto.KeyGeneratorTest)

Aggregations

Ed25519GroupElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519GroupElement)5 Ed25519GroupElement (io.nem.core.crypto.ed25519.arithmetic.Ed25519GroupElement)4 Ed25519EncodedGroupElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement)4 Ed25519EncodedFieldElement (io.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement)3 Ed25519EncodedGroupElement (io.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement)3 Ed25519EncodedFieldElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement)3 Ed25519EncodedFieldElement (com.github.rosklyar.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement)2 Ed25519GroupElement (com.github.rosklyar.crypto.ed25519.arithmetic.Ed25519GroupElement)2 Hasher (io.nem.symbol.core.crypto.Hasher)2 PublicKey (io.nem.symbol.core.crypto.PublicKey)2 CryptoException (com.github.rosklyar.crypto.CryptoException)1 PublicKey (com.github.rosklyar.crypto.PublicKey)1 Signature (com.github.rosklyar.crypto.Signature)1 Ed25519EncodedGroupElement (com.github.rosklyar.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement)1 CryptoException (io.nem.symbol.core.crypto.CryptoException)1 KeyGenerator (io.nem.symbol.core.crypto.KeyGenerator)1 KeyGeneratorTest (io.nem.symbol.core.crypto.KeyGeneratorTest)1 KeyPair (io.nem.symbol.core.crypto.KeyPair)1 Signature (io.nem.symbol.core.crypto.Signature)1 Test (org.junit.jupiter.api.Test)1