Search in sources :

Example 11 with Signature

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

the class Ed25519DsaSignerTest method signThrowsIfGeneratedSignatureIsNotCanonical.

@Test
public void signThrowsIfGeneratedSignatureIsNotCanonical() {
    // Arrange:
    final CryptoEngine engine = this.getCryptoEngine();
    final KeyPair keyPair = KeyPair.random(engine);
    final Ed25519DsaSigner dsaSigner = new Ed25519DsaSigner(keyPair) {

        @Override
        public boolean isCanonicalSignature(Signature signature) {
            return false;
        }
    };
    final byte[] input = RandomUtils.generateRandomBytes();
    // Act:
    Assertions.assertEquals("Generated signature is not canonical", Assertions.assertThrows(CryptoException.class, () -> dsaSigner.sign(input)).getMessage());
}
Also used : KeyPair(io.nem.symbol.core.crypto.KeyPair) CryptoEngine(io.nem.symbol.core.crypto.CryptoEngine) Signature(io.nem.symbol.core.crypto.Signature) DsaSignerTest(io.nem.symbol.core.crypto.DsaSignerTest) Test(org.junit.jupiter.api.Test)

Aggregations

Signature (io.nem.symbol.core.crypto.Signature)11 CryptoEngine (io.nem.symbol.core.crypto.CryptoEngine)7 DsaSigner (io.nem.symbol.core.crypto.DsaSigner)7 DsaSignerTest (io.nem.symbol.core.crypto.DsaSignerTest)7 KeyPair (io.nem.symbol.core.crypto.KeyPair)7 Test (org.junit.jupiter.api.Test)7 BigInteger (java.math.BigInteger)4 Hasher (io.nem.symbol.core.crypto.Hasher)2 Ed25519EncodedFieldElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement)2 CryptoException (io.nem.symbol.core.crypto.CryptoException)1 PublicKey (io.nem.symbol.core.crypto.PublicKey)1 Ed25519EncodedGroupElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement)1 Ed25519GroupElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519GroupElement)1