blob: 3ad449ecca207dbccf97d3074ce7b6443d88cbb3 [file] [log] [blame]
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/**
* @file hash_to_field.h
*
* @author Alexandre Adomnicai
*
* @brief Header file for implementation of standard hash to curve functions according to https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/
*/
#ifndef HASH_TO_FIELD_ZZZ_H
#define HASH_TO_FIELD_ZZZ_H
#include "fp_YYY.h"
#include "config_curve_ZZZ.h"
#define SUCCESS 0x00000000
#define ERR_NULLPOINTER_HASH2FIELD 0x00000401
#define ERR_BADARGLEN_HASH2FIELD 0x00000402
/**
* @brief Hash a byte string msg of arbitrary length into one or more finite
* field elements according to the draft-irtf-cfrg-hash-to-curve-16 spec.
* Relies on expand_message_xmd function with SHA-256.
*
* @param elems Output finite field elements
* @param nelems Number of finite field elements (is 'count * m' from spec)
* @param m Extension degree of finite field (m >= 1)
* @param msg Input byte string
* @param msglen Byte string length (in bytes)
* @param DST Domain separation tag
* @param DSTlen Domain separation tag length (in bytes)
*
* @return 0 if successful, error code otherwise
*/
extern int hash_to_field_YYY(BIG_XXX elems[], unsigned int nelems, unsigned int m,
const char *msg, unsigned int msglen,
const char *DST, unsigned int DSTlen);
#endif