You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <code>marker</code>: <code>0x00</code> (same as SegWit)
350
-
351
400
* <code>flag</code>:
352
-
353
401
** <code>0x02</code> (indicates the presence of attestation data only)
354
402
** <code>0x03</code> (indicates the presence of both witness and attestation data)
355
-
356
403
* <code>attestation</code>: Contains the quantum-resistant public keys and signatures.
357
404
358
-
=== Transaction ID ===
405
+
===Quantum Transaction ID (qtxid)===
359
406
360
407
The transaction ID is computed as the HASH256 of the serialized transaction, including the attestation and witness
361
408
(if a witness is present). When decoded, this is called the qtxid, which will differ from the txid and wtxid if an
@@ -392,23 +439,46 @@ must count the number of inputs present in the transaction.
392
439
The specific quantum-resistant signature algorithm used is inferred from the length of the public key.
393
440
Implementations must recognize the supported algorithms and validate accordingly.
394
441
395
-
Supported PQC algorithms and their NIST Level V parameters:
396
-
397
-
* '''SPHINCS+-256f:'''
398
-
* Public Key Length: 64 bytes
399
-
* Signature Length: 49,856 bytes
400
-
* '''CRYSTALS-Dilithium Level 5:'''
401
-
* Public Key Length: 2,592 bytes
402
-
* Signature Length: 4,595 bytes
403
-
* '''FALCON-1024:'''
404
-
* Public Key Length: 1,793 bytes
405
-
* Signature Length: 1,280 bytes
442
+
Supported PQC algorithms and their NIST Level I parameters:
443
+
444
+
* '''secp256k1 - BIP-340 - Schnorr + X-Only'''
445
+
** Key Type 0
446
+
** Public Key Length: 32 bytes
447
+
** Signature Length: 64 bytes
448
+
** Total Size: 96 bytes
449
+
** Cycles to sign: 42,000 (EdDSA)
450
+
** Cycles to verify: 130,000 (EdDSA)
451
+
* '''FN-DSA-512 - FIPS 206 - FALCON-512:'''
452
+
** Key Type 1
453
+
** Public Key Length: 897 bytes
454
+
** Signature Length: 667 bytes
455
+
** Total Size: 1,564 bytes
456
+
** Cycles to sign: 1,009,764
457
+
** Cycles to verify: 81,036
458
+
* '''ML-DSA-44 - FIPS 204 - CRYSTALS-Dilithium Level I:'''
459
+
** Key Type 2
460
+
** Public Key Length: 1,312 bytes
461
+
** Signature Length: 2,420 bytes
462
+
** Total Size: 3,732 bytes
463
+
** Cycles to sign: 333,013
464
+
** Cycles to verify: 118,412
465
+
* '''SLH-DSA-SHAKE-128s - FIPS 205 - SPHINCS+-128s:'''
466
+
** Key Type 3
467
+
** Public Key Length: 32 bytes
468
+
** Signature Length: 7,856 bytes
469
+
** Total Size: 7,888 bytes
470
+
** Cycles to sign: 4,682,570,992
471
+
** Cycles to verify: 4,764,084
406
472
407
473
Implementations must reject public keys and signatures that do not match expected lengths for supported algorithms.
408
474
409
475
If a new algorithm is added, and one of the byte sizes overlaps, then an additional byte should be prepended to the
410
476
new algorithm's public key length that indicates the specific algorithm used.
411
477
478
+
A bitmask is used to indicate the algorithm used for each public key and signature pair. The bitmask is enumerates based on
479
+
the key type as indicated above. This is used in the cryptographic commitment in the merkle tree hash computation and
480
+
revealed in the attestation when spent.
481
+
412
482
=== Script Validation ===
413
483
414
484
To spend a P2QRH output, the following conditions must be met:
@@ -425,18 +495,24 @@ the <code>scriptPubKey</code>.
425
495
* Valid signatures corresponding to the public key(s) and the transaction data.
426
496
427
497
3. For multi-signature schemes, all required public keys and signatures must be provided for that input within the
428
-
attestation. Public keys that are not needed can be excluded by including their hash in the attestation accompanied
429
-
with an empty signature. This includes classical Schnorr signatures.
498
+
attestation. Public keys that are not needed or available can be selectively disclosed by including their hash in the
499
+
attestation accompanied with an empty signature by providing a 0x00 signature length byte.
430
500
431
501
==== Sighash Calculation ====
432
502
433
-
The sighash for P2QRH outputs follows the same procedure as defined in BIP-0143 for SegWit transactions:
503
+
The sighash for P2QRH outputs follows the same procedure as defined in [https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki BIP-341] for Taproot transactions:
504
+
505
+
* '''Signature Message:''' A single-SHA256 of a tagged hash with the tag "TapSighash", containing transaction data.
506
+
* '''Tagged Hash:''' Computed as H(tag || tag || data) where H is SHA256 and tag is the SHA256 of the tag name.
507
+
* '''Key Data:''' In addition to transaction data, the sighash includes the spent output's scriptPubKey.
508
+
* '''Extension Fields:''' Specific data is included or excluded from the sighash based on the sighash flag.
434
509
435
-
* '''Hash Prevouts:''' Computed over the previous outputs being spent.
436
-
* '''Hash Sequence:''' Computed over the sequence fields.
437
-
* '''Hash Outputs:''' Computed over the outputs of the transaction.
510
+
This signature hash construction ensures transaction malleability is prevented while providing flexibility through
511
+
different sighash types (DEFAULT, ALL, NONE, SINGLE, and ANYONECANPAY variants). The exact computation follows the
512
+
procedure specified in BIP-341 to maintain compatibility with Taproot signatures.
438
513
439
-
The message to be signed includes these hashes, ensuring transaction malleability is prevented.
514
+
If a sighash flag other than DEFAULT is needed, it can be placed in the transaction witness. In this case, it will be
515
+
the only field in the witness.
440
516
441
517
==== Signature Verification ====
442
518
@@ -452,44 +528,44 @@ Signature verification is as follows:
452
528
453
529
3. Verify each signature against the corresponding public key and the sighash.
454
530
455
-
4. Ensure that the signature algorithm used matches the expected lengths for NIST Level V security, and is supported by
531
+
4. Ensure that the signature algorithm used matches the expected lengths for NIST Level I security, and is supported by
456
532
the implementation.
457
533
458
534
==== Attestation Parsing Example ====
459
535
460
-
Signing for a single input using both FALCON-1024 and secp256k1 Schnorr:
536
+
Signing for a single input using both secp256k1 Schnorr and FALCON-512:
461
537
462
538
Number of public keys:
463
539
464
540
[num_pubkeys]: 0x02
465
541
466
542
Pubkey 1:
467
-
[pubkey_length]: 0x0701 (1793 bytes)
468
-
[pubkey]: public_key_falcon_1024
469
-
470
-
Pubkey 2:
471
543
[pubkey_length]: 0x20 (32 bytes)
472
544
[pubkey]: public_key_secp256k1
473
545
546
+
Pubkey 2:
547
+
[pubkey_length]: 0x0701 (1793 bytes)
548
+
[pubkey]: public_key_falcon_512
549
+
474
550
Number of signatures:
475
551
476
552
[num_signatures]: 0x02
477
553
478
554
Signature 1:
479
-
[signature_length]: 0x0500 (1280 bytes)
480
-
[signature]: signature_falcon_1024
481
-
482
-
Signature 2:
483
555
[signature_length]: 0x40 (64 bytes)
484
556
[signature]: signature_secp256k1
485
557
558
+
Signature 2:
559
+
[signature_length]: 0x0500 (1280 bytes)
560
+
[signature]: signature_falcon_512
561
+
486
562
Note: This contrasts with multisig inputs, where the attestation structure repeats for each public key and signature.
487
563
488
564
=== Compatibility with BIP-141 ===
489
565
490
566
By adhering to the SegWit transaction structure and versioning, P2QRH outputs are compatible with existing transaction
491
567
processing rules. Nodes that do not recognize SegWit version 3 will treat these outputs as anyone-can-spend but, per
492
-
BIP-141, will not relay or mine such transactions.
568
+
[https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki BIP-141], will not relay or mine such transactions.
493
569
494
570
=== Usage Considerations ===
495
571
@@ -498,7 +574,7 @@ BIP-141, will not relay or mine such transactions.
498
574
Quantum-resistant signatures are significantly larger than traditional signatures, increasing transaction size and the
499
575
fees required. Users and wallet developers should be aware of this and plan accordingly.
500
576
501
-
For example, for CRYSTALS-Dilithium Level V, a single signature is 4,595 bytes, a substantial increase over current
577
+
For example, for CRYSTALS-Dilithium Level I, a single public key is 1,312 bytes, and a signature is 2,420 bytes, resulting in a substantial increase over current
502
578
ECDSA or Schnorr signatures.
503
579
504
580
==== Performance Impact ====
@@ -615,6 +691,7 @@ seeds to act as the authoritative secret when signing. These measures are deemed
615
691
616
692
To help implementors understand updates to this BIP, we keep a list of substantial changes.
617
693
694
+
* 2025-03-12 - Add verification times for each algorithm. 256 -> 128 (NIST V -> NIST I). Add key type bitmask. Clarify multisig semantics.
618
695
* 2025-02-23 - More points of clarification from review. Update dead link.
619
696
* 2025-01-20 - Remove SQIsign from consideration due to significant performance concerns. Refactor language from long-range attack to long-exposure so as to not be confused with the language around block re-org attacks.
0 commit comments