tests: Add Wycheproof ECDH vectors

Adds a test for the ECDH module using the Wycheproof vectors.
We use a python script to convert the JSON-formatted vectors
into C code, in the same spirit as https://github.com/bitcoin-core/secp256k1/pull/1245

Co-authored-by: Sean Andersen <6730974+andozw@users.noreply.github.com>
This commit is contained in:
RandomLattice
2024-02-03 18:52:22 -05:00
parent 0653a25d50
commit e266ba11ae
10 changed files with 10695 additions and 11 deletions

12
tools/wycheproof_utils.py Normal file
View File

@@ -0,0 +1,12 @@
# Copyright (c) 2024 Random "Randy" Lattice and Sean Andersen
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php.
'''
Utility functions for generating C files for testvectors from the Wycheproof project.
'''
def to_c_array(x):
if x == "":
return ""
s = ',0x'.join(a + b for a, b in zip(x[::2], x[1::2]))
return "0x" + s