// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_MESSAGE = "916c7d1d268fc0e77c1bef238432573c39be577bbea0998936add2b50a653171" +
//         "ce18a542b0b7f96c1691a3be6031522894a8634183eda38798a0c5d5d79fbd01" +
//         "dd04a8646d71873b77b221998a81922d8105f892316369d5224c9983372d2313" +
//         "c6b1f4556ea26ba49d46e8b561e0fc76633ac9766e68e21fba7edca93c4c7460" +
//         "376d7f3ac22ff372c18f613f2ae2e856af40";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_PRIVATE = "b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_PUBLIC = "77f48b59caeda77751ed138b0ec667ff50f8768c25d48309a8f386a2bad187fb";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_SIGNATURE = "6bd710a368c1249923fc7a1610747403040f0cc30815a00f9ff548a896bbda0b" +
//         "4eb2ca19ebcf917f0f34200a9edbad3901b64ab09cc5ef7b9bcc3c40c0ff7509";


import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.abstractj.kalium.encoders.Encoder.HEX;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_MESSAGE;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_PRIVATE;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_PUBLIC;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_SIGNATURE;
import static org.junit.Assert.fail;
/**
 * Copyright 2013 Bruno Oliveira, and individual contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.abstractj.kalium.keys;




public class VerifyKeyTest {

    @Test
    public void testVerifyCorrectRawSignature() throws Exception {
        byte[] rawSignature = HEX.decode(SIGN_SIGNATURE);
        byte[] rawMessage = HEX.decode(SIGN_MESSAGE);
        byte[] rawPublicKey = HEX.decode(SIGN_PUBLIC);
        VerifyKey verifyKey = new VerifyKey(rawPublicKey);
        assertTrue(verifyKey.verify(rawMessage, rawSignature));
    }

    @Test
    public void testVerifyCorrectHexSignature() throws Exception {
        byte[] rawPublicKey = HEX.decode(SIGN_PUBLIC);
        VerifyKey verifyKey = new VerifyKey(rawPublicKey);
        verifyKey.verify(SIGN_MESSAGE, SIGN_SIGNATURE, HEX);
        assertTrue(verifyKey.verify(SIGN_MESSAGE, SIGN_SIGNATURE, HEX));
    }

    @Test
    public void testDetectBadSignature() throws Exception {
        try {
            String badSignature = SIGN_SIGNATURE.concat("0000");
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_MESSAGE = "916c7d1d268fc0e77c1bef238432573c39be577bbea0998936add2b50a653171" +
//         "ce18a542b0b7f96c1691a3be6031522894a8634183eda38798a0c5d5d79fbd01" +
//         "dd04a8646d71873b77b221998a81922d8105f892316369d5224c9983372d2313" +
//         "c6b1f4556ea26ba49d46e8b561e0fc76633ac9766e68e21fba7edca93c4c7460" +
//         "376d7f3ac22ff372c18f613f2ae2e856af40";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_PRIVATE = "b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_PUBLIC = "77f48b59caeda77751ed138b0ec667ff50f8768c25d48309a8f386a2bad187fb";
// 
// Path: src/test/java/org/abstractj/kalium/fixture/TestVectors.java
// public static final String SIGN_SIGNATURE = "6bd710a368c1249923fc7a1610747403040f0cc30815a00f9ff548a896bbda0b" +
//         "4eb2ca19ebcf917f0f34200a9edbad3901b64ab09cc5ef7b9bcc3c40c0ff7509";


// Path: src/test/java/org/abstractj/kalium/keys/VerifyKeyTest.java
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.abstractj.kalium.encoders.Encoder.HEX;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_MESSAGE;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_PRIVATE;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_PUBLIC;
import static org.abstractj.kalium.fixture.TestVectors.SIGN_SIGNATURE;
import static org.junit.Assert.fail;

/**
 * Copyright 2013 Bruno Oliveira, and individual contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.abstractj.kalium.keys;




public class VerifyKeyTest {

    @Test
    public void testVerifyCorrectRawSignature() throws Exception {
        byte[] rawSignature = HEX.decode(SIGN_SIGNATURE);
        byte[] rawMessage = HEX.decode(SIGN_MESSAGE);
        byte[] rawPublicKey = HEX.decode(SIGN_PUBLIC);
        VerifyKey verifyKey = new VerifyKey(rawPublicKey);
        assertTrue(verifyKey.verify(rawMessage, rawSignature));
    }

    @Test
    public void testVerifyCorrectHexSignature() throws Exception {
        byte[] rawPublicKey = HEX.decode(SIGN_PUBLIC);
        VerifyKey verifyKey = new VerifyKey(rawPublicKey);
        verifyKey.verify(SIGN_MESSAGE, SIGN_SIGNATURE, HEX);
        assertTrue(verifyKey.verify(SIGN_MESSAGE, SIGN_SIGNATURE, HEX));
    }

    @Test
    public void testDetectBadSignature() throws Exception {
        try {
            String badSignature = SIGN_SIGNATURE.concat("0000");
            VerifyKey verifyKey = new VerifyKey(SIGN_PUBLIC, HEX);