From b0eaf5e49ec007d375a7d6316959339955b5cdcf Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 1 Nov 2021 09:50:09 +0100 Subject: [PATCH] generator(reseed): concat k with seed, ctr++ also got rid of the redundant ctr variable as we only need the one that is part of G_state. --- generator.cpp | 11 +++++------ generator.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/generator.cpp b/generator.cpp index 593aebc..a766753 100644 --- a/generator.cpp +++ b/generator.cpp @@ -15,12 +15,11 @@ struct G_state{ unsigned __int128 ctr; }; -auto reseed(G_state G, const string& s) -> std::tuple { - unsigned __int128 ctr; - // TODO(me): conctatenate the key with seed - G.k = do_sha(G.ctr); - // return G, will need to get just k from that - return {G, ctr}; +auto reseed(G_state G, const string& s) -> G_state { + string to_be_hashed = std::to_string(G.k) + s; + G.k = do_sha(stoul(to_be_hashed)); + G.ctr++; + return G; } auto do_sha(int64_t key_with_seed) -> int64_t { diff --git a/generator.h b/generator.h index 3732a57..51142b7 100644 --- a/generator.h +++ b/generator.h @@ -15,7 +15,7 @@ G_state *initialize_generator(); auto do_crypto(int64_t k, unsigned __int128 ctr) -> std::string; -auto reseed(G_state G, const std::string& s) -> std::tuple; +auto reseed(G_state G, const std::string& s) -> G_state; auto do_sha(int64_t key_with_seed) -> int64_t;