aboutsummaryrefslogtreecommitdiff
path: root/src/gen/seed.c
diff options
context:
space:
mode:
authorJ08nY2017-09-07 16:22:22 +0200
committerJ08nY2017-09-07 16:22:22 +0200
commit49a9aee1b0b997f874f0fea2d45d4f6fdf1af325 (patch)
tree30eed1d630fe3bbe27670d4403d8efbf8d3585c1 /src/gen/seed.c
parent964395cd920883645a3f065a0fcf6785b9a85acc (diff)
downloadecgen-49a9aee1b0b997f874f0fea2d45d4f6fdf1af325.tar.gz
ecgen-49a9aee1b0b997f874f0fea2d45d4f6fdf1af325.tar.zst
ecgen-49a9aee1b0b997f874f0fea2d45d4f6fdf1af325.zip
Diffstat (limited to 'src/gen/seed.c')
-rw-r--r--src/gen/seed.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gen/seed.c b/src/gen/seed.c
index 71b6658..628dad5 100644
--- a/src/gen/seed.c
+++ b/src/gen/seed.c
@@ -123,9 +123,15 @@ static void seed_hash(seed_t *seed) {
}
static void seed_W(seed_t *seed, const config_t *cfg) {
- GEN t = utoi(cfg->bits - 1);
+ GEN t = utoi(cfg->bits);
GEN s = floorr(rdivii(subis(t, 1), stoi(160), DEFAULTPREC));
- GEN h = subis(t, 160);
+ GEN h = subii(t, mulis(s, 160));
+ GEN hash = binascii_btoi(seed->hash20, 20, ENDIAN_BIG);
+ GEN mask = subis(int2n(itos(h)), 1);
+ // TODO: what if I get zeros at the beginning? 0123 == 123 for PARI t_INT
+ // I should just convert to a t_VECSMALL of bits from the seed->hash and do everything with that.
+ // That's alot of custom code to handle bit strings.
+ GEN c0 = ibitand(hash, mask);
}
GENERATOR(seed_gen_random) {