Skip to content

nqdcommit(3)

nqdcommit, nqdreveal, nqdcite — commitments and citations of a data record

libnqd, -lnqd -lnoqtis

#include <nqd.h>

int
nqdcommit(const uint8_t *salt, size_t sl, const uint8_t *m, size_t n, char hex[65]);

int
nqdreveal(const nqdrec *r, const uint8_t *salt, size_t sl, const uint8_t *m, size_t n, size_t *idx);

int
nqdcite(const nqdrec *r, int fmt, char *out, size_t cap, size_t *outlen);

() writes to hex the 64 lower-case hex digits (and a NUL) of the commitment to the n bytes at m under the secret salt of sl bytes, 16 to 1,024 (take 32 from nqrand(3)): SHA3-256 of the string ‘noqtis-commit-1’ with its NUL, the salt's length as 8 bytes big-endian, the salt and the bytes. The tag keeps the digest from passing for any other digest noqtis makes; the length fixes where the salt ends. Put it in a ‘commits’ element with nqdput(3).

() computes the same over m and salt and compares it with every ‘commits’ digest of r, each in constant time; on a match *idx (when not NULL) gets the element's index.

() writes the record's ‘cite’ as a CITATION.cff 1.2.0 (NQDCFF) or a BibTeX entry (NQDBIB) to out, as nqdjson(3) writes.

NQOK; nqdreveal(): NQEVRFY when no commitment matches; nqdcite(): NQEIO when there is no ‘cite’, NQEBUF for a cap too small; NQEARG for a salt out of bounds or an unknown format.

noqtis-cite(1), noqtis-commit(1), noqtis-reveal(1), nqdnew(3), noqtis-data(5)