generator(reseed): concat k with seed, ctr++
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
also got rid of the redundant ctr variable as we only need the one that is part of G_state.
This commit is contained in:
parent
7d123ce639
commit
b0eaf5e49e
|
@ -15,12 +15,11 @@ struct G_state{
|
|||
unsigned __int128 ctr;
|
||||
};
|
||||
|
||||
auto reseed(G_state G, const string& s) -> std::tuple<G_state, unsigned __int128> {
|
||||
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 {
|
||||
|
|
|
@ -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<G_state, unsigned __int128>;
|
||||
auto reseed(G_state G, const std::string& s) -> G_state;
|
||||
|
||||
auto do_sha(int64_t key_with_seed) -> int64_t;
|
||||
|
||||
|
|
Reference in New Issue