From ca6a2d5a870e1e1cea54a67e9330bced4e58f1fe Mon Sep 17 00:00:00 2001 From: "Jeff R. Allen" Date: Tue, 14 Apr 2020 11:51:56 +0200 Subject: [PATCH] Test vectors. --- LowCostDP3T.py | 20 ++++++++++++++++++++ README.md | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/LowCostDP3T.py b/LowCostDP3T.py index 9cd47d2..4173f70 100644 --- a/LowCostDP3T.py +++ b/LowCostDP3T.py @@ -277,3 +277,23 @@ def next_day(self): def next_epoch(self): self.ctmgr.process_epoch() + +# Generate test vectors +if __name__ == "__main__": + def hex(y): + return ''.join( [ "%02x" % x for x in y ] ) + + ks = KeyStore() + ks.SKt.insert(0, b"\0" * 32) + print("sk0", hex(ks.SKt[0])) + e = ks.create_ephIDs(ks.SKt[0]) + print("ephID[0]", hex(e[0])) + print("ephID[1]", hex(e[1])) + print("ephID[95]", hex(e[95])) + + ks.rotate_SK() + print("sk1", hex(ks.SKt[0])) + e = ks.create_ephIDs(ks.SKt[0]) + print("ephID[0]", hex(e[0])) + print("ephID[1]", hex(e[1])) + print("ephID[95]", hex(e[95])) diff --git a/README.md b/README.md index 537606c..35e3924 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,20 @@ and `rotate_ephIDs` which creates the set of `ephIDs` for the new day. These methods are straight forward implementations of the description in the whitepaper. +LowCostDP3T.py, when run standalone, will generate test vectors to help +other implementors check their work: + +``` +$ python3 ./LowCostDP3T.py +sk0 0000000000000000000000000000000000000000000000000000000000000000 +ephID[0] 8fd521e6c47060efcbfdb9b801c30743 +ephID[1] d86e56bb702117b8cf20dc4aadd42310 +ephID[95] f38403173134f2c65682ee799e817ef3 +sk1 66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 +ephID[0] fda0fff97c5566886c5afcb0c7333f73 +ephID[1] 1d1ae795488b0ad0e4aba33d4bed3f4a +ephID[95] b832b76cb203226cd7297f8483c60b76 +``` ## Contact tracing: `ContactManager`