From 33a99a1a17a569493cbf009bcd5458939c153f54 Mon Sep 17 00:00:00 2001 From: josibake Date: Mon, 15 Jan 2024 12:05:08 +0100 Subject: Add reference.py with test vectors * reference.py contains the silent payment specific code * secp256k1.py for doing the EC operations * bech32m.py contains code for encoding/decoding bech32(m) addresses * bitcoin_utils.py contains some helper code, not specific to silent payments * send_and_receive_test_vectors.json contains the wallet unit test vectors Co-Authored-By: S3RK <1466284+S3RK@users.noreply.github.com> Co-Authored-By: Oghenovo Usiwoma <37949128+Eunovo@users.noreply.github.com> Co-authored-by: S.Blagogee <34041358+setavenger@users.noreply.github.com> --- bip-0352.mediawiki | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'bip-0352.mediawiki') diff --git a/bip-0352.mediawiki b/bip-0352.mediawiki index 2f8f767..8f41bca 100644 --- a/bip-0352.mediawiki +++ b/bip-0352.mediawiki @@ -370,6 +370,58 @@ If using a seed/seed phrase only style backup, the user can recover the wallet's Silent payments introduces a new address format and protocol for sending and as such is not compatible with older wallet software or wallets which have not implemented the silent payments protocol. +== Test Vectors == + +A [[bip-0352/send_and_receive_test_vectors.json|collection of test vectors in JSON format]] are provided, along with a [[bip-0352/reference.py|python reference implementation]]. Each test vector consists of a sending test case and corresponding receiving test case. This is to allow sending and receiving to be implemented separately. To ensure determinism while testing, sort the array of ''Bm'' by amount (see the [[bip-0352/reference.py|reference implementation]]). Test cases use the following schema: + +''' test_case ''' + + { + "comment": "Comment describing the behavior being tested", + "sending": [], + "receiving": [], + } + +''' sender ''' + + { + "given": { + "vin": [], + "recipients": [] + }, + "expected": { + "outputs": [], + "n_outouts": , + }, + } + +''' recipient ''' + + { + "given": { + "vin": [], + "key_material": { + "scan_priv_key": , + "spend_priv_key": , + } + "labels": [], + }, + "expected": { + "addresses": [], + "outputs": [ + { + "priv_key_tweak": , + "pub_key": , + "signature": + }, + ... + ], + "n_outputs": + } + } + +Wallets should include inputs not in the ''[[#inputs-for-shared-secret-derivation|Inputs For Shared Secret Derivation]]'' list when testing to ensure that only inputs from the list are being used for shared secret derivation. Additionally, receiving wallets should include non-silent payment outputs for themselves in testing to ensure silent payments scanning does not interfere with regular outputs detection. + === Functional tests === Below is a list of functional tests which should be included in sending and receiving implementations. -- cgit v1.2.3