0374 - Draft - Standards - Dec. 26, 2024 (1 year, 6 months ago)
26
2024
BIP: 374
Layer: Applications
Title: Discrete Log Equality Proofs
Author: Andrew Toth <[email protected]>
Ruben Somsen <[email protected]>
Sebastian Falbesoner <[email protected]>
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 374
Status: Draft
Type: Standards Track
Created: 2024-12-26
License: BSD-2-Clause
Post-History: https://gist.github.com/andrewtoth/df97c3260cc8d12f09d3855ee61322ea
https://groups.google.com/g/bitcoindev/c/MezoKV5md7s
This document proposes a standard for 64-byte zero-knowledge discrete logarithm equality proofs (DLEQ proofs) over an elliptic curve. For given elliptic curve points A , B , C , G , and a scalar a known only to the prover where A = a⋅G and C = a⋅B , the prover proves knowledge of a without revealing anything about a . This can, for instance, be useful in ECDH: if A and B are ECDH public keys, and C is their ECDH shared secret computed as C = a⋅B , the proof establishes that the same secret key a is used for generating both A and C without revealing a .
This document is licensed under the 2-clause BSD license.
BIP 352 requires senders to compute output scripts using ECDH shared secrets from the same secret keys used to sign the inputs. Generating an incorrect signature will produce an invalid transaction that will be rejected by consensus. An incorrectly generated output script can still be consensus-valid, meaning funds may be lost if it gets broadcast. By producing a DLEQ proof for the generated ECDH shared secrets, the signing entity can prove to other entities that the output scripts have been generated correctly without revealing the private keys.
All conventions and notations are used as defined in BIP 327 .
The basic proof generation uses a random scalar k , the secret a , and the point being proven C = a⋅B .
Providing only C , e and s as a proof does not reveal a or k .
Verifying the proof involves recreating R 1 and R 2 with only e and s as follows:
This can be verified by substituting s = (k + e⋅a) :
Thus verifying e = hash(R 1 || R 2 ) proves the discrete logarithm equivalency of A and C .
The following generates a proof that the result of a⋅B and the result of a⋅G are both generated from the same scalar a without having to reveal a .
Input:
The algorithm GenerateProof(a, B, r, G, m) is defined as:
The following verifies the proof generated in the previous section. If the following algorithm succeeds, the points A and C were both generated from the same scalar. The former from multiplying by G , and the latter from multiplying by B .
Input:
The algorithm VerifyProof(A, B, C, proof, G, m) is defined as:
This proposal is compatible with all older clients.
A reference python implementation is included
here
.
Test vectors can be generated by running
./bip-0374/gen_test_vectors.py
which will produce a CSV
file of random test vectors for both generating and verifying proofs.
These can be run against the reference implementation with
./bip-0374/run_test_vectors.py
.
Thanks to josibake, Tim Ruffing, benma, stratospher, waxwing, Yuval Kogman and all others who participated in discussions on this topic.