taker.podle
taker.podle
Proof of Discrete Log Equivalence (PoDLE) generation for takers.
This module re-exports PoDLE generation functions from jmcore and provides taker-specific utilities for UTXO selection and commitment generation.
PoDLE is used to prevent sybil attacks in JoinMarket by requiring takers to prove ownership of a UTXO without revealing which UTXO until after the maker commits to participate.
Protocol flow: 1. Taker generates commitment \(C = H(P_2)\) where \(P_2 = k \cdot J\) (\(k\) = private key, \(J\) = NUMS point) 2. Taker sends commitment \(C\) to maker 3. Maker accepts and sends pubkey 4. Taker reveals \(P\), \(P_2\), \(\text{sig}\), \(e\) as the "revelation" 5. Maker verifies: \(P = k \cdot G\) and \(P_2 = k \cdot J\) (same \(k\))
Reference: https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8
Attributes
__all__ = ['ExtendedPoDLECommitment', 'PoDLECommitment', 'PoDLEError', 'generate_podle', 'get_eligible_podle_utxos', 'select_podle_utxo', 'serialize_revelation']
module-attribute
Classes
ExtendedPoDLECommitment
PoDLE commitment with extended UTXO metadata for neutrino_compat feature.
This extends the base PoDLECommitment with scriptpubkey and blockheight for Neutrino-compatible UTXO verification.
Source code in taker/src/taker/podle.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
Attributes
blockheight: int | None = None
class-attribute
instance-attribute
commitment: PoDLECommitment
instance-attribute
e: bytes
property
Challenge e
index: int
property
NUMS point index used
p: bytes
property
Public key P = k*G
p2: bytes
property
Commitment point P2 = k*J
scriptpubkey: str | None = None
class-attribute
instance-attribute
sig: bytes
property
Schnorr signature s
utxo: str
property
UTXO reference txid:vout
Methods:
has_neutrino_metadata() -> bool
Check if we have metadata for Neutrino-compatible verification.
Source code in taker/src/taker/podle.py
111 112 113 | |
to_commitment_str() -> str
Get commitment as hex string.
Source code in taker/src/taker/podle.py
107 108 109 | |
to_revelation(extended: bool = False) -> dict[str, str]
Convert to revelation format for sending to maker.
Args: extended: If True, include scriptpubkey:blockheight in utxo string
Source code in taker/src/taker/podle.py
93 94 95 96 97 98 99 100 101 102 103 104 105 | |
PoDLECommitment
PoDLE commitment data generated by taker.
Source code in jmcore/src/jmcore/podle.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
Attributes
commitment: bytes
instance-attribute
e: bytes
instance-attribute
index: int
instance-attribute
p: bytes
instance-attribute
p2: bytes
instance-attribute
sig: bytes
instance-attribute
utxo: str
instance-attribute
Methods:
to_commitment_str() -> str
Get commitment as string with type prefix.
JoinMarket requires a commitment type prefix to allow future commitment schemes. "P" indicates a standard PoDLE commitment. Format: "P" + hex(commitment)
Source code in jmcore/src/jmcore/podle.py
105 106 107 108 109 110 111 112 113 | |
to_revelation() -> dict[str, str]
Convert to revelation format for sending to maker.
Source code in jmcore/src/jmcore/podle.py
95 96 97 98 99 100 101 102 103 | |
PoDLEError
Bases: Exception
PoDLE generation or verification error.
Source code in jmcore/src/jmcore/podle.py
73 74 75 76 | |
Functions:
generate_podle(private_key_bytes: bytes, utxo_str: str, index: int = 0) -> PoDLECommitment
Generate a PoDLE commitment for a UTXO.
The PoDLE proves that the taker owns the UTXO without revealing the private key. It creates a zero-knowledge proof that: P = kG and P2 = kJ have the same discrete log k.
Args: private_key_bytes: 32-byte private key utxo_str: UTXO reference as "txid:vout" index: NUMS point index (0-255)
Returns: PoDLECommitment with all proof data
Source code in jmcore/src/jmcore/podle.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
get_eligible_podle_utxos(utxos: list[UTXOInfo], cj_amount: int, min_confirmations: int = 5, min_percent: int = 20) -> list[UTXOInfo]
Get all eligible UTXOs for PoDLE commitment, sorted by preference.
Criteria: - Must have at least min_confirmations - Must be at least min_percent of cj_amount
Returns: List of eligible UTXOs sorted by (confirmations, value) descending
Source code in taker/src/taker/podle.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
select_podle_utxo(utxos: list[UTXOInfo], cj_amount: int, min_confirmations: int = 5, min_percent: int = 20) -> UTXOInfo | None
Select the best UTXO for PoDLE commitment.
Args: utxos: Available UTXOs cj_amount: CoinJoin amount min_confirmations: Minimum confirmations required min_percent: Minimum value as percentage of cj_amount
Returns: Best UTXO for PoDLE or None if no suitable UTXO
Source code in taker/src/taker/podle.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
serialize_revelation(commitment: PoDLECommitment) -> str
Serialize PoDLE revelation to wire format.
Format: utxo|P|P2|sig|e (pipe-separated strings)
Source code in jmcore/src/jmcore/podle.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |