[#SipHasher13UJ]
= SipHasher13UJ
:mrdocs:

A custom weaker variant of SipHash&hyphen;1&hyphen;3 without padding, and supporting &quot;jumbo&quot; inputs&period;

== Synopsis

Declared in `&lt;crypto&sol;siphash&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class SipHasher13UJ;
----

== Description

Compared to the traditional SipHash&hyphen;2&hyphen;4, this incorporates 3 changes&colon;

* Use SipHash&hyphen;1&hyphen;3&colon; This common variant reduces the number of rounds between input blocks from 2 to 1, and the number of finalization rounds at the end from 4 to 3&period; It is a standard faster choice with weaker security guarantees&period; It is considered strong enough for use in hash tables and other applications with only weak security requirements, in particular when attackers cannot directly observe the hash function output, and cannot control k0 and k1&period;

* Remove padding&colon; Standard SipHash operates on byte&hyphen;oriented inputs, which are converted into 8&hyphen;byte blocks internally by adding a padding of 1&hyphen;8 bytes to obtain a multiple of 8 bytes&period; In this variant, the input is a sequence of blocks instead, which are used without padding&period; This saves 1 round for inputs that are a multiple of 8 bytes already&period; The padding normally adds a commitment to the input&apos;s byte length, but since our input is block oriented, and there is one round per input, the function of that commitment is directly fulfilled by the number of rounds&period; The empty input is permitted&semi; it yields the result of finalizing the initialization directly&period; Out of an abundance of caution the finalizing v2 &circ;&equals; 0xff is changed to v2 &circ;&equals; 0x6465646461706e75 (&quot;unpadded&quot; in LE64), to avoid collisions between standard SipHash&hyphen;1&hyphen;3 and this variant&period;

* Jumbo blocks&colon; We generalize the input to consist of a sequence of blocks which are each either exactly 8 bytes (normal blocks) or 32 bytes (jumbo blocks), and may be arbitrarily mixed&period; For hash&hyphen;table use, cryptographic hash outputs must make up all but a small bounded number of retained jumbo blocks&period; Note that the block structure matters&colon; hashing one jumbo block is not the same as hashing the same data split up into four normal blocks&period; Jumbo blocks are interpreted as 4 LE64 integers (d0,d1,d2,d3), and XOR&apos;ed into the state before a round as (v0,v1,v2,v3) &circ;&equals; (d1,d2,d3,d0), and XOR&apos;ed into the state after a round as (v0,v1,v2,v3) &circ;&equals; (d0,d1,d2,d3)&period; This is a strict generalization of normal block processing, in the sense that if d1&period;&period;d3&equals;0, it is identical to processing a normal block d0 (a single LE64 integer)&period; Of course, making d1&period;&period;d3&equals;0 should be impossible in the output of a cryptographic hash function&period; These jumbo blocks are acceptable because even though they may give the attacker more control within a single round, that control is limited by the cryptographic hash in between&period;

Other components are unchanged&colon; initialization constants, SipRound, and 64&hyphen;bit output&period; This interface serves as an executable specification for fixed&hyphen;width implementations&period; The Hash overloads optimize fixed&hyphen;width inputs without modifying the accumulated state&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:SipHasher13UJ/2constructor.adoc[`SipHasher13UJ`]         [.small]#[constructor]#
| Construct a SipHash&hyphen;1&hyphen;3&hyphen;UJ calculator initialized with 128&hyphen;bit key (k0, k1)&period;
| xref:SipHasher13UJ/Finalize.adoc[`Finalize`] 
| Compute the 64&hyphen;bit SipHash&hyphen;1&hyphen;3&hyphen;UJ of the data written so far&period; The object remains untouched&period;
| xref:SipHasher13UJ/Hash-051.adoc[`Hash`] 
| `Hash` overloads
| xref:SipHasher13UJ/Write.adoc[`Write`] 
| Hash a normal 64&hyphen;bit value&period;
| xref:SipHasher13UJ/WriteJumbo.adoc[`WriteJumbo`] 
| Hash a 256&hyphen;bit value as a jumbo block&period; For hash&hyphen;table use, non&hyphen;hash inputs must remain few and bounded&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:txindex-02/CreateKeyPrefix.adoc[`txindex&colon;&colon;CreateKeyPrefix`]
| Compute the txid&hyphen;hash key prefix for a transaction&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
