standard_questions

Undocumented in source.
static immutable
auto standard_questions = ["What is your favorite book?", "What is the name of the road you grew up on?", "What is your mother’s maiden name?", "What was the name of your first/current/favorite pet?", "What was the first company that you worked for?", "Where did you meet your spouse?", "Where did you go to high school/college?", "What is your favorite food?", "What city were you born in?", "Where is your favorite place to vacation?"];

Examples

import std.array : join;
import tagion.crypto.SecureNet : StdHashNet;

auto selected_questions = indexed(standard_questions, [0, 2, 3, 7, 8]).array.idup;
string[] answers = [
    "mobidick",
    "Mother Teresa!",
    "Pluto",
    "Pizza",
    "Maputo"
];
const net = new StdHashNet;
auto recover = KeyRecover(net);
recover.createKey(selected_questions, answers, 3);

auto R = new ubyte[net.hashSize];

{ // All the ansers are correct
    const result = recover.findSecret(R, selected_questions, answers);
    assert(R.length == net.hashSize);
    assert(result); // Password found
}

{ // 3 out of 5 answers are correct. This is a valid answer to generate the secret key
    string[] good_answers = [
        "MobiDick",
        "MOTHER TERESA",
        "Fido",
        "pizza",
        "Maputo"
    ];
    auto goodR = new ubyte[net.hashSize];
    const result = recover.findSecret(goodR, selected_questions, good_answers);
    assert(R.length == net.hashSize);
    assert(result); // Password found
    assert(R == goodR);
}

{ // 2 out of 5 answers are correct. This is NOT a valid answer to generate the secret key
    string[] bad_answers = [
        "mobidick",
        "Monalisa",
        "Fido",
        "Burger",
        "Maputo"
    ];
    auto badR = new ubyte[net.hashSize];
    const result = recover.findSecret(badR, selected_questions, bad_answers);
    assert(!result); // Password not found
    assert(R != badR);

}

Meta