|
| template<typename Hash , typename MessageContainer , typename KeyContainer > |
| std::array< uint8_t, Hash::OUTPUT_SIZE > | hmac (const MessageContainer &message, const KeyContainer &key) |
| | Compute an HMAC given a secret key and a message.
|
| |
template<typename Hash , typename Fr , typename MessageContainer , typename KeyContainer >
requires (Hash::OUTPUT_SIZE == 32) |
| Fr | get_unbiased_field_from_hmac (const MessageContainer &message, const KeyContainer &key) |
| | Takes a size-HASH_OUTPUT buffer from HMAC and converts into a field element.
|
| |
|
| TEST (Pedersen, Commitment) |
| |
|
| TEST (Pedersen, CommitmentWithZero) |
| |
|
| TEST (Pedersen, CommitmentProf) |
| |
|
| TEST (Pedersen, GeneratorPrinter) |
| |
|
| TEST (Pedersen, Hash) |
| |
|
| TEST (Pedersen, HashWithIndex) |
| |
AES-128 Cipher
Implements AES-128 block cipher, and buffer encryption using cbc cipher chaining
Based off of tiny-AES by @kokke : https://github.com/kokke/tiny-AES-c
template<typename Hash , typename
Fr , typename MessageContainer , typename KeyContainer >
requires (Hash::OUTPUT_SIZE == 32)
| Fr crypto::get_unbiased_field_from_hmac |
( |
const MessageContainer & |
message, |
|
|
const KeyContainer & |
key |
|
) |
| |
Takes a size-HASH_OUTPUT buffer from HMAC and converts into a field element.
We assume HASH_OUTPUT = 32. Reducing HMAC(key, message) modulo r would result in an unacceptable bias. We hash input with 0 and 1 to produce 64 bytes of input data. This is then converted into a uin512_t, which is taken modulo Fr::modulus to produce our field element, where the statistical bias is negligble in the security parameter.
- Template Parameters
-
| Hash | the hash function we're using |
| Fr | field type |
| MessageContainer | a byte container (std::vector<uint8_t>, std::array<uint8_t, ...>, std::string) |
| KeyContainer | a byte container |
- Parameters
-
| message | the input buffer |
| key | key used to derive |
- Returns
- Fr output field element as uint512_t( H(10...0 || HMAC(k,m)) || H(00...0 || HMAC(k,m)) ) % r