disco icon indicating copy to clipboard operation
disco copied to clipboard

test vectors?

Open mimoo opened this issue 7 years ago • 4 comments

mimoo avatar Oct 03 '18 11:10 mimoo

For testing purposes I think it would be better to have an option to "disable" all crypto randomness, and just set all random results to zero. So all private keys and nonces will be zero, and it allows to implement test vectors and achieve deterministic results.

In c-like languages we can use preprocessor directive (like I do in DiscoNet), in others (go and python) the only way to deal with it is to define global variables for the same purpose.

The only places to add this is GenerateKeyPair, EncryptAndAuthenticate, Encrypt.

Fasjeit avatar Nov 27 '18 08:11 Fasjeit

If possible, I think it'd be good to follow the Noise test vectors format.

I test for them here and they require you to set the ephemeral key for each test. So in my Noise implementation I have an extra field


type handshakeState struct {
    // ...
    // for test vectors
    debugEphemeral *KeyPair
}

(Now that I'm thinking about it, I probably don't need this extra field since I'm inside the library.)

If you want I can get that done this week end, as I already have this code it should be pretty straight forward for me to output the test vectors instead of reading from them.

mimoo avatar Nov 27 '18 15:11 mimoo

I got the idea about Key Pairs, but what about the nonces? As we call Ad operation on random nonce the state is updated in non deterministic way, so each call give new strobe state.

I don't need test vectors right now. I have some other "Disco" things to do at this moment, so don't hurry.

Fasjeit avatar Nov 27 '18 19:11 Fasjeit

Are you talking about the nonces of the symmetric library? In this case I don't think it is necessary to cover this via the test vectors since we already cover strobe with test vectors and this is a pretty simple wrapper around strobe.

mimoo avatar Nov 28 '18 04:11 mimoo