# Realize a MAC using a Pseudo-random function?

Given a pseudo-random function and assuming that we do not have any other tools, How can we construct a MAC?

I believe this can be done. Would like to know if there is more than one way of doing this.

If you have a PRF (with larger input than output), you can use it as compression function in a Merkle-Damgård structure, yielding a hash function which you can subsequently turn into a MAC with HMAC. Indeed, the security proof of HMAC relies on indistinguishability of the compression function from a PRF.

There are still an awful lot of details, though. And the PRF assumption is quite strong.

• Just to quibble over minor points, I think NMAC makes more sense than HMAC here (since you're starting with a compression function, rather than a hash function), and I believe the requirement is that the output has to be at least as long as the PRF key (since you'd be chaining through the key input). – Seth Feb 19 '12 at 10:03

If you have a keyed PRF, where the key is sufficient to turn the function into an independent PRF, you can turn it into a keyed PRP using a Luby Rackoff construct. If you got a keyed PRP, you can use it in CBC-MAC mode.

I am not sure if $\mathsf{PRF}$ alone can be used to construct; however there is a natural way to construct $\mathsf{MAC}$ using $\mathsf{PRF}$ and $\mathsf{UHF}$. You can see the following papers for more detail:

1. LFSR-based hashing and authentication. In CRYPTO 1994.
2. Bucket hashing and its application to fast message authentication. In CRYPTO 1995.
3. On fast and provably secure message authentication based on universal hashing. In CRYPTO 1996.

I just found a very easy way to construct $\mathsf{MAC}$ from $\mathsf{PRF}$ in the lecture notes of Barak. More concisely, it says that if $\{ f_k \}_{k \in \mathcal{K}}$ is a family of $\mathsf{PRF}$, then the following is a $\mathsf{MAC}$:

$$\mathsf{SIGN}_k(x) = f_k(x) \qquad \mathsf{VERIFY}_k(x,s)=1 \text{ iff } f_k(x)=s.$$

I think this is pretty neat.

• I think the exact details depend from the used definition of pseudo-random function. If you have one that allows input of any size (like a hash function and the $f_k$ used here), it is a lot easier than if you have one with fixed input size. – Paŭlo Ebermann Feb 20 '12 at 20:17
{"ft_lang_label":"__label__en","ft_lang_prob":0.8897137,"math_prob":0.97386503,"size":1793,"snap":"2020-24-2020-29","text_gpt3_token_len":461,"char_repetition_ratio":0.122973725,"word_repetition_ratio":0.22580644,"special_character_ratio":0.2437256,"punctuation_ratio":0.092391305,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99574226,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-07T04:10:51Z\",\"WARC-Record-ID\":\"<urn:uuid:525e06a6-073e-47e0-82db-2aeeddb7f444>\",\"Content-Length\":\"161095\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:05b1f6da-a2e9-43ea-b3cf-49357222df46>\",\"WARC-Concurrent-To\":\"<urn:uuid:19b0a57b-4b42-443f-a6e7-b191978b3bb3>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://crypto.stackexchange.com/questions/1881/realize-a-mac-using-a-pseudo-random-function\",\"WARC-Payload-Digest\":\"sha1:MLXHQ36TO7LFTALS3GNBHTVLY3EOFYVC\",\"WARC-Block-Digest\":\"sha1:MWPMDJCWQM4CWGMPZDKUSD62IG7BOXQY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655891640.22_warc_CC-MAIN-20200707013816-20200707043816-00416.warc.gz\"}"}