title: Salted, per table-cell hashing in a database
body: <p>I'm trying to come up with a good strategy for salting each row's column value in an SQL table with [semi-] <em>independent</em> salts for each cell. Ideally, I'd prefer a setup with only 1 secret salt per table, with the salt of each table-cell derived from (i.e. determined algorithmically) from that 1 secret salt.</p>
  <p>The reason why I need a new salt per table-cell is that I need to advertise the hash of each column value without giving away its value. (I'll compute each cell's hash by concatenating the cell's value to its salt and then compute the hash of that byte sequence.)</p>
  <p>A simple strategy I have in mind for generating the per-table-cell <em>salt</em> is to say generate a secret, secure 32-byte random byte sequence for table, call it R_32, and then for each cell compute the SHA-256 of R_32 concatenated with the cell's coordinates. In pseudo code:</p>
  <p><code>salt(row,col) = SHA_256( R_32 + row + col)</code></p>
  <p>where <code>+</code> here represents byte-string concatenation (not addition).</p>
  <p>This way, I can both advertise a table-cell's hash, and if necessary, later prove the contents of that cell generated the hash (by exposing only that cell's salt and it contents).</p>
  <p>I'm a mathy programmer with some working (application-level) knowledge of cryptographic principles, but not a cryptographer. So 2 general questions:</p>
  <ol>
  <li><p>Is the above <code>salt(row,col)</code> function secure? (I obviously think it should be, but there may be subtleties)</p>
  </li>
  <li><p>I feel I can't be the first person tackling this problem of deriving multiple salts from a single secret salt. My searches come up naught however. Maybe they even wrote about it. If so, any pointers much appreciated.</p>
  </li>
  </ol>
  <p>Thank you</p>