Ejemplo n.º 1
0
    public void example_crypto_sign_seed_keypair()
    {
        Console.WriteLine("Example: crypto_sign_seed_keypair()");

        byte[] seed = new byte[] {
            0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
            0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
            0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
        };

        byte[] pk  = new byte[crypto_sign_PUBLICKEYBYTES];
        byte[] sk  = new byte[crypto_sign_SECRETKEYBYTES];
        byte[] pk2 = new byte[crypto_sign_PUBLICKEYBYTES];
        byte[] sk2 = new byte[crypto_sign_SECRETKEYBYTES];

        LibSalt.crypto_sign_seed_keypair(pk, sk, seed);
        LibSalt.crypto_sign_seed_keypair(pk2, sk2, seed);

        Console.WriteLine("Keypair One: ");
        Console.WriteLine("pk: " + LibSalt.ByteArrayToString(pk));
        Console.WriteLine("sk: " + LibSalt.ByteArrayToString(sk));

        Console.WriteLine("Keypair Two: ");
        Console.WriteLine("pk: " + LibSalt.ByteArrayToString(pk2));
        Console.WriteLine("sk: " + LibSalt.ByteArrayToString(sk2));
        Console.WriteLine();
    }
Ejemplo n.º 2
0
    public void test_crypto_sign_seed_keypair()
    {
        Console.WriteLine("Testing crypto_sign_seed_keypair() .....");

        byte[] pk  = new byte[crypto_sign_PUBLICKEYBYTES];
        byte[] sk  = new byte[crypto_sign_SECRETKEYBYTES];
        byte[] pk2 = new byte[crypto_sign_PUBLICKEYBYTES];
        byte[] sk2 = new byte[crypto_sign_SECRETKEYBYTES];
        LibSalt.crypto_sign_seed_keypair(pk, sk, seed);
        LibSalt.crypto_sign_seed_keypair(pk2, sk2, seed);

        // Test for proper pk and sk array sizes
        UnitTest.ASSERT_EQUALS(pk.Length, crypto_sign_PUBLICKEYBYTES);
        UnitTest.ASSERT_EQUALS(sk.Length, crypto_sign_SECRETKEYBYTES);

        // Test for generating same pk/sk for same seed
        UnitTest.ASSERT_SAME_DATA(pk, pk2);
        UnitTest.ASSERT_SAME_DATA(sk, sk2);
    }