Adding bip39 so I can use it to move around private keys.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4725 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
22
src/tests.c
22
src/tests.c
@ -1,9 +1,11 @@
|
||||
#include "tests.h"
|
||||
|
||||
#include "bip39.h"
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.tests.h"
|
||||
#include "util.js.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
@ -670,6 +672,25 @@ static void _test_b64(const tf_test_options_t* options)
|
||||
unlink("out/test.js");
|
||||
}
|
||||
|
||||
static const char* k_bip39_test_key_base64 = "GO0Lv5BvcuuJJdHrokHoo0PmCDC/XjO/SZ6H+ddq4UvWd/VPW1RJrjd1aCUIfPIojFXrWMb8R54vVerU2TwjdQ==.ed25519";
|
||||
static const char* k_bip32_test_key_words = "body hair useful camp warm into cause riot two bamboo kick educate dinosaur advice seed type crisp where guilt avocado output rely lunch goddess";
|
||||
|
||||
static void _test_bip39(const tf_test_options_t* options)
|
||||
{
|
||||
uint8_t bytes[64] = { 0 };
|
||||
tf_base64_decode(k_bip39_test_key_base64, strlen(k_bip39_test_key_base64) - strlen(".ed25519"), bytes, sizeof(bytes));
|
||||
char words[4096] = "";
|
||||
bool result = tf_bip39_bytes_to_words(bytes, sizeof(bytes) / 2, words, sizeof(words));
|
||||
tf_printf("%d: %s\n", result, words);
|
||||
assert(result);
|
||||
assert(strcmp(words, k_bip32_test_key_words) == 0);
|
||||
|
||||
uint8_t test_bytes[32] = { 0 };
|
||||
result = tf_bip39_words_to_bytes(k_bip32_test_key_words, test_bytes, sizeof(test_bytes));
|
||||
assert(result);
|
||||
assert(memcmp(bytes, test_bytes, sizeof(test_bytes)) == 0);
|
||||
}
|
||||
|
||||
typedef struct _test_http_t
|
||||
{
|
||||
uv_loop_t* loop;
|
||||
@ -796,6 +817,7 @@ static void _tf_test_run(const tf_test_options_t* options, const char* name, voi
|
||||
void tf_tests(const tf_test_options_t* options)
|
||||
{
|
||||
#if !TARGET_OS_IPHONE
|
||||
_tf_test_run(options, "bip39", _test_bip39, false);
|
||||
_tf_test_run(options, "http", _test_http, false);
|
||||
_tf_test_run(options, "ssb", tf_ssb_test_ssb, false);
|
||||
_tf_test_run(options, "ssb_id", tf_ssb_test_id_conversion, false);
|
||||
|
Reference in New Issue
Block a user