Why not HMAC?

Reply to this note

Please Login to reply.

Discussion

this is simpler

there is a good reason cryptography is not simple

do you have a preimage attack on sha256?

no. but there is hmac (enforcing clear separation of key/data) and I cannot see why you do not want to use it

why not hkdf ?

as I write it up I'm leaning toward this (pns = private note storage):

// device_key is users nsec or device nsec

pns_key = hkdf(device_key, "nipXX")

pns_nip44_key = hkdf(pns_key, "nip44-v2")

ctext = nip44_encrypt(pns_nip44_key, nonce, note_json)

for non-fixed-length sure

i guess hkdf_extract is basically hmac anyways