Skip to content

Commit

Permalink
bip340: Add subsection on Domain Separation
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Jul 29, 2022
1 parent d472fe7 commit 4a1ace6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bip-0340.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ the algorithms of the signature scheme will perform more hashing internally.
In particular, the hashing performed by the signing algorithm will process the message twice,
which leads to performance penalties for large messages.

==== Domain Separation ====

It is good cryptographic practice to use a key pair only for a single purpose.
Nevertheless, there may be situations in which it may be desirable to use the same key pair in multiple contexts,
i.e., to sign different types of messages within the same application
or even messages in entirely different applications
(e.g., a secret key may be used to sign Bitcoin transactions as well plain text messages).

As a consequence, applications should ensure that a signed application message intended for one context is never deemed valid in a different context
(e.g., a signed plain text message should never be misinterpreted as a signed Bitcoin transaction, because this could cause unintended loss of funds).
This is called "domain separation" and it is typically realized by partitioning the message space.
Even if key pairs are intended to be used only within a single context,
domain separation is a good idea because it makes it easy to add more contexts later.

As a best practice, we recommend applications to use exactly one of the following methods to pre-process application messages before passing it to the signature scheme:
* Either, pre-hash the application message using ''hash<sub>name</sub>'', where ''name'' identifies the context uniquely (e.g., "foo-app/signed-bar"),
* or prefix the actual message with a 33-byte string that identifies the context uniquely (e.g. the UTF-8 enconding of "foo-app/signed-bar", padded with null bytes to 33 bytes).
As the two pre-processing methods yield different message sizes (32 bytes vs. at least 33 bytes), there is no risk of collision between them.

== Applications ==

There are several interesting applications beyond simple signatures.
Expand Down

0 comments on commit 4a1ace6

Please sign in to comment.