diff options
| author | J08nY | 2017-05-01 21:36:33 +0200 |
|---|---|---|
| committer | J08nY | 2017-05-01 21:36:33 +0200 |
| commit | e990fed4bc44fb78d25b898bf2d271d1cb1cb92c (patch) | |
| tree | 1574ed910b6e97336a93fbcea2373f9b02d3a46c /src/exhaustive/seed.c | |
| parent | 67132e9095402696a892f7114a2d477c5b559fdd (diff) | |
| parent | 4b07f578ec1075dafc329929a0323738ee65af20 (diff) | |
| download | ecgen-e990fed4bc44fb78d25b898bf2d271d1cb1cb92c.tar.gz ecgen-e990fed4bc44fb78d25b898bf2d271d1cb1cb92c.tar.zst ecgen-e990fed4bc44fb78d25b898bf2d271d1cb1cb92c.zip | |
Diffstat (limited to 'src/exhaustive/seed.c')
| -rw-r--r-- | src/exhaustive/seed.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/exhaustive/seed.c b/src/exhaustive/seed.c index bd6f274..d35fc05 100644 --- a/src/exhaustive/seed.c +++ b/src/exhaustive/seed.c @@ -61,15 +61,38 @@ static GEN seed_stoi(const char *cstr) { return gerepilecopy(ltop, seed); } +char *seed_itos(GEN seed) { + pari_sp ltop = avma; + GEN bits = binary_zv(seed); + + long len = glength(bits); + long bytes = (len / 8) + (len % 8 == 0 ? 0 : 1); + char *result = pari_malloc((size_t)bytes); + if (!result) { + perror("Couldn't malloc."); + exit(1); + } + + for (long i = 0; i < len; ++i) { + // TODO + } + avma = ltop; + return result; +} + int seed_random(curve_t *curve, const config_t *cfg, arg_t *args) { curve->seed = seed_new(); curve->seed->seed = random_int(160); + curve->seed->raw = seed_itos(curve->seed->seed); + curve->seed->raw_len = strlen(curve->seed->raw); return 1; } int seed_argument(curve_t *curve, const config_t *cfg, arg_t *args) { curve->seed = seed_new(); curve->seed->seed = seed_stoi(cfg->seed); + curve->seed->raw = cfg->seed; + curve->seed->raw_len = strlen(cfg->seed); return 1; } |
