Unverified Commit 339c9194 authored by Sofia Celi's avatar Sofia Celi

Change name of functions and variables

parent 940fbb33
......@@ -19,10 +19,10 @@
#include <decaf/ed448.h>
/* Template stuff */
#define API_NS(_id) decaf_448_##_id
#define SCALAR_BITS DECAF_448_SCALAR_BITS
#define SCALAR_SER_BYTES DECAF_448_SCALAR_BYTES
#define SCALAR_LIMBS DECAF_448_SCALAR_LIMBS
#define API_NS(_id) goldilocks_448_##_id
#define SCALAR_BITS GOLDILOCKS_448_SCALAR_BITS
#define SCALAR_SER_BYTES GOLDILOCKS_448_SCALAR_BYTES
#define SCALAR_LIMBS GOLDILOCKS_448_SCALAR_LIMBS
#define scalar_t API_NS(scalar_t)
#define point_t API_NS(point_t)
#define precomputed_s API_NS(precomputed_s)
......@@ -48,7 +48,7 @@ static const scalar_t point_scalarmul_adjustment = {{{
const uint8_t decaf_x448_base_point[DECAF_X448_PUBLIC_BYTES] = { 0x05 };
#define RISTRETTO_FACTOR DECAF_448_RISTRETTO_FACTOR
#define RISTRETTO_FACTOR GOLDILOCKS_448_RISTRETTO_FACTOR
const gf RISTRETTO_FACTOR = {FIELD_LITERAL(
0x42ef0f45572736, 0x7bf6aa20ce5296, 0xf4fd6eded26033, 0x968c14ba839a66, 0xb8d54b64a2d780, 0x6aa0a1f1a7b8a5, 0x683bf68d722fa2, 0x22d962fbeb24f7
)};
......
......@@ -19,7 +19,7 @@
#include "f_field.h"
#include "decaf.h"
#define API_NS(_id) decaf_448_##_id
#define API_NS(_id) goldilocks_448_##_id
static const unsigned char base_point_ser_for_pregen[SER_BYTES] = {
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33
};
......@@ -90,7 +90,7 @@ int main(int argc, char **argv) {
printf("/** @warning: this file was automatically generated. */\n");
printf("#include \"field.h\"\n\n");
printf("#include <decaf.h>\n\n");
printf("#define API_NS(_id) decaf_448_##_id\n");
printf("#define API_NS(_id) goldilocks_448_##_id\n");
output = (const gf_s *)real_point_base;
printf("const API_NS(point_t) API_NS(point_base) = {{\n");
......
......@@ -3,7 +3,7 @@
#include <decaf.h>
#define API_NS(_id) decaf_448_##_id
#define API_NS(_id) goldilocks_448_##_id
const API_NS(point_t) API_NS(point_base) = {{
{FIELD_LITERAL(0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0080000000000000,0x00fffffffffffffe,0x00ffffffffffffff,0x00ffffffffffffff,0x007fffffffffffff)},
{FIELD_LITERAL(0x006079b4dfdd4a64,0x000c1e3ab470a1c8,0x0044d73f48e5199b,0x0050452714141818,0x004c74c393d5242c,0x0024080526437050,0x00d48d06c13078ca,0x008508de14f04286)},
......
......@@ -17,8 +17,8 @@
#include <decaf/shake.h>
#include <string.h>
#define API_NAME "decaf_448"
#define API_NS(_id) decaf_448_##_id
#define API_NAME "goldilocks_448"
#define API_NS(_id) goldilocks_448_##_id
#define hash_ctx_t decaf_shake256_ctx_t
#define hash_init decaf_shake256_init
......@@ -122,7 +122,7 @@ void decaf_ed448_derive_secret_scalar (
* the decaf base point is on Etwist_d, and when converted it effectively
* picks up a factor of 2 from the isogenies. So we might start at 2 instead of 1.
*/
for (unsigned int c=1; c < DECAF_448_EDDSA_ENCODE_RATIO; c <<= 1) {
for (unsigned int c=1; c < GOLDILOCKS_448_EDDSA_ENCODE_RATIO; c <<= 1) {
API_NS(scalar_halve)(secret,secret);
}
......@@ -194,7 +194,7 @@ void decaf_ed448_sign (
/* Scalarmul to create the nonce-point */
API_NS(scalar_t) nonce_scalar_2;
API_NS(scalar_halve)(nonce_scalar_2,nonce_scalar);
for (unsigned int c = 2; c < DECAF_448_EDDSA_ENCODE_RATIO; c <<= 1) {
for (unsigned int c = 2; c < GOLDILOCKS_448_EDDSA_ENCODE_RATIO; c <<= 1) {
API_NS(scalar_halve)(nonce_scalar_2,nonce_scalar_2);
}
......@@ -291,7 +291,7 @@ decaf_error_t decaf_ed448_verify (
DECAF_EDDSA_448_PRIVATE_BYTES
);
for (unsigned c=1; c<DECAF_448_EDDSA_DECODE_RATIO; c<<=1) {
for (unsigned c=1; c<GOLDILOCKS_448_EDDSA_DECODE_RATIO; c<<=1) {
API_NS(scalar_add)(response_scalar,response_scalar,response_scalar);
}
......
......@@ -16,13 +16,13 @@
#include <decaf.h>
/* Template stuff */
#define API_NS(_id) decaf_448_##_id
#define API_NS(_id) goldilocks_448_##_id
#define point_t API_NS(point_t)
#define COFACTOR 4
static const int EDWARDS_D = -39081;
/* This is prob also not needed */
#define RISTRETTO_FACTOR DECAF_448_RISTRETTO_FACTOR
#define RISTRETTO_FACTOR GOLDILOCKS_448_RISTRETTO_FACTOR
extern const gf RISTRETTO_FACTOR;
/* End of template stuff */
......
......@@ -16,10 +16,10 @@
#include <decaf.h>
/* Template stuff */
#define API_NS(_id) decaf_448_##_id
#define SCALAR_BITS DECAF_448_SCALAR_BITS
#define SCALAR_SER_BYTES DECAF_448_SCALAR_BYTES
#define SCALAR_LIMBS DECAF_448_SCALAR_LIMBS
#define API_NS(_id) goldilocks_448_##_id
#define SCALAR_BITS GOLDILOCKS_448_SCALAR_BITS
#define SCALAR_SER_BYTES GOLDILOCKS_448_SCALAR_BYTES
#define SCALAR_LIMBS GOLDILOCKS_448_SCALAR_LIMBS
#define scalar_t API_NS(scalar_t)
static const decaf_word_t MONTGOMERY_FACTOR = (decaf_word_t)0x3bd440fae918bc5ull;
......
......@@ -54,7 +54,7 @@ extern "C" {
#define DECAF_WORD_BITS 32 /**< The number of bits in a word */
#endif
#endif
#if DECAF_WORD_BITS == 64
typedef uint64_t decaf_word_t; /**< Word size for internal computations */
typedef int64_t decaf_sword_t; /**< Signed word size for internal computations */
......
......@@ -48,10 +48,10 @@ extern "C" {
#define decaf_ed448_prehash_destroy decaf_shake256_destroy
/** EdDSA encoding ratio. */
#define DECAF_448_EDDSA_ENCODE_RATIO 4
#define GOLDILOCKS_448_EDDSA_ENCODE_RATIO 4
/** EdDSA decoding ratio. */
#define DECAF_448_EDDSA_DECODE_RATIO (4 / 4)
#define GOLDILOCKS_448_EDDSA_DECODE_RATIO (4 / 4)
/**
* @brief EdDSA key secret key generation. This function uses a different (non-Decaf)
......@@ -61,7 +61,7 @@ extern "C" {
* @param [in] privkey The private key.
*/
void decaf_ed448_derive_secret_scalar (
decaf_448_scalar_t secret,
goldilocks_448_scalar_t secret,
const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
......@@ -192,7 +192,7 @@ decaf_error_t decaf_ed448_verify_prehash (
/**
* @brief EdDSA point encoding. Used internally, exposed externally.
* Multiplies by DECAF_448_EDDSA_ENCODE_RATIO first.
* Multiplies by GOLDILOCKS_448_EDDSA_ENCODE_RATIO first.
*
* The multiplication is required because the EdDSA encoding represents
* the cofactor information, but the Decaf encoding ignores it (which
......@@ -201,35 +201,35 @@ decaf_error_t decaf_ed448_verify_prehash (
* representation doesn't track it.
*
* The way libdecaf handles this is to multiply by
* DECAF_448_EDDSA_DECODE_RATIO when decoding, and by
* DECAF_448_EDDSA_ENCODE_RATIO when encoding. The product of these
* GOLDILOCKS_448_EDDSA_DECODE_RATIO when decoding, and by
* GOLDILOCKS_448_EDDSA_ENCODE_RATIO when encoding. The product of these
* ratios is always exactly the cofactor 4, so the cofactor
* ends up cleared one way or another. But exactly how that shakes
* out depends on the base points specified in RFC 8032.
*
* The upshot is that if you pass the Decaf/Ristretto base point to
* this function, you will get DECAF_448_EDDSA_ENCODE_RATIO times the
* this function, you will get GOLDILOCKS_448_EDDSA_ENCODE_RATIO times the
* EdDSA base point.
*
* @param [out] enc The encoded point.
* @param [in] p The point.
*/
void decaf_448_point_mul_by_ratio_and_encode_like_eddsa (
void goldilocks_448_point_mul_by_ratio_and_encode_like_eddsa (
uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES],
const decaf_448_point_t p
const goldilocks_448_point_t p
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA point decoding. Multiplies by DECAF_448_EDDSA_DECODE_RATIO,
* @brief EdDSA point decoding. Multiplies by GOLDILOCKS_448_EDDSA_DECODE_RATIO,
* and ignores cofactor information.
*
* See notes on decaf_448_point_mul_by_ratio_and_encode_like_eddsa
* See notes on goldilocks_448_point_mul_by_ratio_and_encode_like_eddsa
*
* @param [out] enc The encoded point.
* @param [in] p The point.
*/
decaf_error_t decaf_448_point_decode_like_eddsa_and_mul_by_ratio (
decaf_448_point_t p,
decaf_error_t goldilocks_448_point_decode_like_eddsa_and_mul_by_ratio (
goldilocks_448_point_t p,
const uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES]
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
......
This diff is collapsed.
This diff is collapsed.
......@@ -116,7 +116,7 @@ for curve,data in curve_data.items():
data["bits"] = ceil_log2(data["modulus"])
if "c_ns" not in data:
data["c_ns"] = "decaf_" + str(data["bits"])
data["c_ns"] = "goldilocks_" + str(data["bits"])
data["C_NS"] = data["c_ns"].upper()
......@@ -54,7 +54,7 @@ extern "C" {
#define DECAF_WORD_BITS 32 /**< The number of bits in a word */
#endif
#endif
#if DECAF_WORD_BITS == 64
typedef uint64_t decaf_word_t; /**< Word size for internal computations */
typedef int64_t decaf_sword_t; /**< Signed word size for internal computations */
......@@ -96,7 +96,7 @@ decaf_successful(decaf_error_t e) {
decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS);
return (w-1)>>DECAF_WORD_BITS;
}
/** Overwrite data with zeros. Uses memset_s if available. */
void decaf_bzero (
void *data,
......@@ -109,9 +109,9 @@ decaf_bool_t decaf_memeq (
const void *data2,
size_t size
) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_API_VIS;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __DECAF_COMMON_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment