16
$\begingroup$

In RFC5647, NIST SP 800-38D, etc., || is used to denote concatenation. How did that come to be?

In most programming languages || represents "or" and + denotes concatenation and the fact that crypto texts just kind of mixed it up seems to make for an easy gotcha.

$\endgroup$
2
  • $\begingroup$ Don't remember how it started to appears in articles, however, using plus was confusing with math plus if you don't carefully look at the notation of the articles. $\endgroup$
    – kelalaka
    Dec 24, 2018 at 11:39
  • 6
    $\begingroup$ I'd argue that it's programming languages that use weird notation. The symbol for logical or has as far as I can tell always been $\lor$. So there isn't really any confusion. $\endgroup$
    – Maeher
    Dec 24, 2018 at 11:53

2 Answers 2

16
$\begingroup$

The origin is set theory and not programming languages. In the context of cryptography, I could describe a set that is $$x_1 \parallel x_2 \parallel \dots \parallel x_n$$ as a concatenation of the series described by $$\parallel_{i=1}^n x_i.$$ Furthermore, it's worth noting that + to a mathematician would suggest that it is a commutative, which might not be true depending on the set (as we could have a set of functions).

$\endgroup$
2
  • 5
    $\begingroup$ While I agree that the notation comes from mathematics, I'm not sure exactly what you mean by "a set that is [...] a concatenation sum". I've seen $\|$ used to denote the concatenation of strings or tuples, such that if $a = (1,2)$ and $b = (3,4,5)$, then $a\,\|\,b = (1,2,3,4,5)$, and of course one can naturally generalize this to sets of strings or tuples, but I'm not sure if that's what you mean. Or what, if anything, rational numbers have to do with any of it. $\endgroup$ Dec 24, 2018 at 21:29
  • $\begingroup$ @IlmariKaronen Good points, I will update the answer to reflect that. I was being lazy as it's a holiday here. The real numbers note was just me pointing to that cryptography uses numbers. My work usually has concatenation of functions in a set; however, the set is bounded so I cannot just have general statements without something running out of the bounds. $\endgroup$
    – b degnan
    Dec 25, 2018 at 2:26
9
$\begingroup$

Some languages like PL/I and Oracle Database SQL indeed use || for string concatenation.

One reason is maybe that + might be confusing when talking about fundamental cryptography, since there is a lot of math involved. The mathematical notation for 'OR' would be reversed caret $\lor$ and the exclusive 'OR', better known as 'XOR' is a circled plus $\oplus$.

But I don't think that there is a specific reason for using || for a string concatenation. If anything then I would presume that someone used it once early and then it has become accustomed until it has become a standard for cryptography.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.