Browse Source

IsoE25519 is now better known as Ristretto

master
Michael Hamburg 7 years ago
parent
commit
98bfcb0196
8 changed files with 51 additions and 42 deletions
  1. +1
    -1
      src/GENERATED/include/decaf.hxx
  2. +5
    -5
      src/GENERATED/include/decaf/ed255.hxx
  3. +12
    -9
      src/GENERATED/include/decaf/point_255.hxx
  4. +2
    -0
      src/GENERATED/include/decaf/point_448.hxx
  5. +3
    -1
      src/generator/curve_data.py
  6. +2
    -0
      src/per_curve/point.tmpl.hxx
  7. +11
    -11
      test/ristretto_vectors.inc.cxx
  8. +15
    -15
      test/vectors.inc.cxx

+ 1
- 1
src/GENERATED/include/decaf.hxx View File

@@ -21,7 +21,7 @@
namespace decaf { namespace decaf {
template <template<typename Group> class Run> template <template<typename Group> class Run>
void run_for_all_curves() { void run_for_all_curves() {
Run<IsoEd25519>::run();
Run<Ristretto>::run();
Run<Ed448Goldilocks>::run(); Run<Ed448Goldilocks>::run();
} }
} }


+ 5
- 5
src/GENERATED/include/decaf/ed255.hxx View File

@@ -43,8 +43,8 @@ namespace decaf {
/** A public key for crypto over some Group */ /** A public key for crypto over some Group */
template <typename Group> struct EdDSA; template <typename Group> struct EdDSA;


/** A public key for crypto over Iso-Ed25519 */
template<> struct EdDSA<IsoEd25519> {
/** A public key for crypto over Ristretto */
template<> struct EdDSA<Ristretto> {


/** @cond internal */ /** @cond internal */
template<class CRTP, Prehashed> class Signing; template<class CRTP, Prehashed> class Signing;
@@ -190,7 +190,7 @@ private:
public: public:
/** Underlying group */ /** Underlying group */
typedef IsoEd25519 Group;
typedef Ristretto Group;
/** Signature size. */ /** Signature size. */
static const size_t SIG_BYTES = DECAF_EDDSA_25519_SIGNATURE_BYTES; static const size_t SIG_BYTES = DECAF_EDDSA_25519_SIGNATURE_BYTES;
@@ -364,7 +364,7 @@ public:
/* PERF FUTURE: Pre-cached decoding? Precomputed table?? */ /* PERF FUTURE: Pre-cached decoding? Precomputed table?? */
/** Underlying group */ /** Underlying group */
typedef IsoEd25519 Group;
typedef Ristretto Group;
/** Signature size. */ /** Signature size. */
static const size_t SIG_BYTES = DECAF_EDDSA_25519_SIGNATURE_BYTES; static const size_t SIG_BYTES = DECAF_EDDSA_25519_SIGNATURE_BYTES;
@@ -417,7 +417,7 @@ public:
} }
}; /* class PublicKey */ }; /* class PublicKey */


}; /* template<> struct EdDSA<IsoEd25519> */
}; /* template<> struct EdDSA<Ristretto> */


#undef DECAF_NOEXCEPT #undef DECAF_NOEXCEPT
} /* namespace decaf */ } /* namespace decaf */


+ 12
- 9
src/GENERATED/include/decaf/point_255.hxx View File

@@ -53,10 +53,10 @@ namespace decaf {
/** /**
* Curve25519/Decaf instantiation of group. * Curve25519/Decaf instantiation of group.
*/ */
struct IsoEd25519 {
struct Ristretto {


/** The name of the curve */ /** The name of the curve */
static inline const char *name() { return "Iso-Ed25519"; }
static inline const char *name() { return "Ristretto"; }


/** The name of the curve */ /** The name of the curve */
static inline int bits() { return 255; } static inline int bits() { return 255; }
@@ -756,15 +756,15 @@ public:
} }
}; };


}; /* struct IsoEd25519 */
}; /* struct Ristretto */


/** @cond internal */ /** @cond internal */
inline SecureBuffer IsoEd25519::Scalar::direct_scalarmul (
const FixedBlock<IsoEd25519::Point::SER_BYTES> &in,
inline SecureBuffer Ristretto::Scalar::direct_scalarmul (
const FixedBlock<Ristretto::Point::SER_BYTES> &in,
decaf_bool_t allow_identity, decaf_bool_t allow_identity,
decaf_bool_t short_circuit decaf_bool_t short_circuit
) const /*throw(CryptoException)*/ { ) const /*throw(CryptoException)*/ {
SecureBuffer out(IsoEd25519::Point::SER_BYTES);
SecureBuffer out(Ristretto::Point::SER_BYTES);
if (DECAF_SUCCESS != if (DECAF_SUCCESS !=
decaf_255_direct_scalarmul(out.data(), in.data(), s, allow_identity, short_circuit) decaf_255_direct_scalarmul(out.data(), in.data(), s, allow_identity, short_circuit)
) { ) {
@@ -773,9 +773,9 @@ inline SecureBuffer IsoEd25519::Scalar::direct_scalarmul (
return out; return out;
} }


inline decaf_error_t IsoEd25519::Scalar::direct_scalarmul_noexcept (
FixedBuffer<IsoEd25519::Point::SER_BYTES> &out,
const FixedBlock<IsoEd25519::Point::SER_BYTES> &in,
inline decaf_error_t Ristretto::Scalar::direct_scalarmul_noexcept (
FixedBuffer<Ristretto::Point::SER_BYTES> &out,
const FixedBlock<Ristretto::Point::SER_BYTES> &in,
decaf_bool_t allow_identity, decaf_bool_t allow_identity,
decaf_bool_t short_circuit decaf_bool_t short_circuit
) const DECAF_NOEXCEPT { ) const DECAF_NOEXCEPT {
@@ -783,6 +783,9 @@ inline decaf_error_t IsoEd25519::Scalar::direct_scalarmul_noexcept (
} }
/** @endcond */ /** @endcond */


typedef Ristretto IsoEd25519;


#undef DECAF_NOEXCEPT #undef DECAF_NOEXCEPT
} /* namespace decaf */ } /* namespace decaf */




+ 2
- 0
src/GENERATED/include/decaf/point_448.hxx View File

@@ -783,6 +783,8 @@ inline decaf_error_t Ed448Goldilocks::Scalar::direct_scalarmul_noexcept (
} }
/** @endcond */ /** @endcond */




#undef DECAF_NOEXCEPT #undef DECAF_NOEXCEPT
} /* namespace decaf */ } /* namespace decaf */




+ 3
- 1
src/generator/curve_data.py View File

@@ -23,8 +23,9 @@ field_data = {


curve_data = { curve_data = {
"curve25519" : { "curve25519" : {
"altname" : "IsoEd25519",
"iso_to" : "Curve25519", "iso_to" : "Curve25519",
"name" : "Iso-Ed25519",
"name" : "Ristretto",
"cofactor" : 8, "cofactor" : 8,
"field" : "p25519", "field" : "p25519",
"scalar_bits" : 253, "scalar_bits" : 253,
@@ -43,6 +44,7 @@ curve_data = {
"eddsa_sigma_iso": 1 "eddsa_sigma_iso": 1
}, },
"ed448goldilocks" : { "ed448goldilocks" : {
"altname": None,
"name" : "Ed448-Goldilocks", "name" : "Ed448-Goldilocks",
"cofactor" : 4, "cofactor" : 4,
"field" : "p448", "field" : "p448",


+ 2
- 0
src/per_curve/point.tmpl.hxx View File

@@ -770,5 +770,7 @@ inline decaf_error_t $(cxx_ns)::Scalar::direct_scalarmul_noexcept (
} }
/** @endcond */ /** @endcond */


$("typedef %s %s;\n" % (cxx_ns,altname) if altname else "")

#undef DECAF_NOEXCEPT #undef DECAF_NOEXCEPT
} /* namespace decaf */ } /* namespace decaf */

+ 11
- 11
test/ristretto_vectors.inc.cxx View File

@@ -1,12 +1,12 @@
template <typename Group> struct base_multiples; template <typename Group> struct base_multiples;


/* Examples for multiples of base point */ /* Examples for multiples of base point */
template <> struct base_multiples<IsoEd25519> {
template <> struct base_multiples<Ristretto> {
static const int count = 16; static const int count = 16;
static const uint8_t values[count][IsoEd25519::Point::SER_BYTES];
static const uint8_t values[count][Ristretto::Point::SER_BYTES];
}; };
const uint8_t base_multiples<IsoEd25519>::values
[base_multiples<IsoEd25519>::count][IsoEd25519::Point::SER_BYTES] = {
const uint8_t base_multiples<Ristretto>::values
[base_multiples<Ristretto>::count][Ristretto::Point::SER_BYTES] = {
/* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */ /* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{226, 242, 174, 10, 106, 188, 78, 113, 168, 132, 169, 97, 197, 0, 81, 95, 88, 227, 11, 106, 165, 130, 221, 141, 182, 166, 89, 69, 224, 141, 45, 118}, {226, 242, 174, 10, 106, 188, 78, 113, 168, 132, 169, 97, 197, 0, 81, 95, 88, 227, 11, 106, 165, 130, 221, 141, 182, 166, 89, 69, 224, 141, 45, 118},
@@ -101,13 +101,13 @@ const uint8_t base_multiples<Ed448Goldilocks>::values[][Ed448Goldilocks::Point::
template <typename Group> struct elligator_examples; template <typename Group> struct elligator_examples;


/* Examples for Elligator */ /* Examples for Elligator */
template <> struct elligator_examples<IsoEd25519> {
template <> struct elligator_examples<Ristretto> {
static const int count = 16; static const int count = 16;
static const uint8_t inputs[count][IsoEd25519::Point::HASH_BYTES];
static const uint8_t outputs[count][IsoEd25519::Point::SER_BYTES];
static const uint8_t inputs[count][Ristretto::Point::HASH_BYTES];
static const uint8_t outputs[count][Ristretto::Point::SER_BYTES];
}; };
const uint8_t elligator_examples<IsoEd25519>::inputs
[elligator_examples<IsoEd25519>::count][IsoEd25519::Point::HASH_BYTES] = {
const uint8_t elligator_examples<Ristretto>::inputs
[elligator_examples<Ristretto>::count][Ristretto::Point::HASH_BYTES] = {
/* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */ /* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */
{184, 249, 135, 49, 253, 123, 89, 113, 67, 160, 6, 239, 7, 105, 211, 41, 192, 249, 185, 57, 9, 102, 70, 198, 15, 127, 7, 26, 160, 102, 134, 71}, {184, 249, 135, 49, 253, 123, 89, 113, 67, 160, 6, 239, 7, 105, 211, 41, 192, 249, 185, 57, 9, 102, 70, 198, 15, 127, 7, 26, 160, 102, 134, 71},
{229, 14, 241, 227, 75, 9, 118, 60, 128, 153, 226, 21, 183, 217, 91, 136, 98, 0, 231, 156, 124, 77, 82, 139, 142, 134, 164, 169, 169, 62, 250, 52}, {229, 14, 241, 227, 75, 9, 118, 60, 128, 153, 226, 21, 183, 217, 91, 136, 98, 0, 231, 156, 124, 77, 82, 139, 142, 134, 164, 169, 169, 62, 250, 52},
@@ -126,8 +126,8 @@ const uint8_t elligator_examples<IsoEd25519>::inputs
{210, 207, 228, 56, 155, 116, 207, 54, 84, 195, 251, 215, 249, 199, 116, 75, 109, 239, 196, 251, 194, 246, 252, 228, 70, 146, 156, 35, 25, 39, 241, 4}, {210, 207, 228, 56, 155, 116, 207, 54, 84, 195, 251, 215, 249, 199, 116, 75, 109, 239, 196, 251, 194, 246, 252, 228, 70, 146, 156, 35, 25, 39, 241, 4},
{34, 116, 123, 9, 8, 40, 93, 189, 9, 103, 57, 103, 66, 227, 3, 2, 157, 107, 134, 219, 202, 74, 230, 154, 78, 107, 219, 195, 214, 14, 84, 80} {34, 116, 123, 9, 8, 40, 93, 189, 9, 103, 57, 103, 66, 227, 3, 2, 157, 107, 134, 219, 202, 74, 230, 154, 78, 107, 219, 195, 214, 14, 84, 80}
}; };
const uint8_t elligator_examples<IsoEd25519>::outputs
[elligator_examples<IsoEd25519>::count][IsoEd25519::Point::SER_BYTES] = {
const uint8_t elligator_examples<Ristretto>::outputs
[elligator_examples<Ristretto>::count][Ristretto::Point::SER_BYTES] = {
/* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */ /* Copy-pasted from Dalek, thanks Isis Lovecruft and Henry de Valence */
{176, 157, 237, 97, 66, 29, 140, 166, 168, 94, 26, 157, 212, 216, 229, 160, 195, 246, 232, 239, 169, 112, 63, 193, 64, 32, 152, 69, 11, 190, 246, 86}, {176, 157, 237, 97, 66, 29, 140, 166, 168, 94, 26, 157, 212, 216, 229, 160, 195, 246, 232, 239, 169, 112, 63, 193, 64, 32, 152, 69, 11, 190, 246, 86},
{234, 141, 77, 203, 181, 225, 250, 74, 171, 62, 15, 118, 78, 212, 150, 19, 131, 14, 188, 238, 194, 244, 141, 138, 166, 162, 83, 122, 228, 201, 19, 26}, {234, 141, 77, 203, 181, 225, 250, 74, 171, 62, 15, 118, 78, 212, 150, 19, 131, 14, 188, 238, 194, 244, 141, 138, 166, 162, 83, 122, 228, 201, 19, 26},


+ 15
- 15
test/vectors.inc.cxx View File

@@ -1,18 +1,18 @@


/* X25519, X448 test vectors */ /* X25519, X448 test vectors */
template<> const uint8_t Tests<IsoEd25519>::rfc7748_1[32] = {
template<> const uint8_t Tests<Ristretto>::rfc7748_1[32] = {
0x42,0x2c,0x8e,0x7a,0x62,0x27,0xd7,0xbc, 0x42,0x2c,0x8e,0x7a,0x62,0x27,0xd7,0xbc,
0xa1,0x35,0x0b,0x3e,0x2b,0xb7,0x27,0x9f, 0xa1,0x35,0x0b,0x3e,0x2b,0xb7,0x27,0x9f,
0x78,0x97,0xb8,0x7b,0xb6,0x85,0x4b,0x78, 0x78,0x97,0xb8,0x7b,0xb6,0x85,0x4b,0x78,
0x3c,0x60,0xe8,0x03,0x11,0xae,0x30,0x79 0x3c,0x60,0xe8,0x03,0x11,0xae,0x30,0x79
}; };
template<> const uint8_t Tests<IsoEd25519>::rfc7748_1000[32] = {
template<> const uint8_t Tests<Ristretto>::rfc7748_1000[32] = {
0x68,0x4c,0xf5,0x9b,0xa8,0x33,0x09,0x55, 0x68,0x4c,0xf5,0x9b,0xa8,0x33,0x09,0x55,
0x28,0x00,0xef,0x56,0x6f,0x2f,0x4d,0x3c, 0x28,0x00,0xef,0x56,0x6f,0x2f,0x4d,0x3c,
0x1c,0x38,0x87,0xc4,0x93,0x60,0xe3,0x87, 0x1c,0x38,0x87,0xc4,0x93,0x60,0xe3,0x87,
0x5f,0x2e,0xb9,0x4d,0x99,0x53,0x2c,0x51 0x5f,0x2e,0xb9,0x4d,0x99,0x53,0x2c,0x51
}; };
template<> const uint8_t Tests<IsoEd25519>::rfc7748_1000000[32] = {
template<> const uint8_t Tests<Ristretto>::rfc7748_1000000[32] = {
0x7c,0x39,0x11,0xe0,0xab,0x25,0x86,0xfd, 0x7c,0x39,0x11,0xe0,0xab,0x25,0x86,0xfd,
0x86,0x44,0x97,0x29,0x7e,0x57,0x5e,0x6f, 0x86,0x44,0x97,0x29,0x7e,0x57,0x5e,0x6f,
0x3b,0xc6,0x01,0xc0,0x88,0x3c,0x30,0xdf, 0x3b,0xc6,0x01,0xc0,0x88,0x3c,0x30,0xdf,
@@ -53,7 +53,7 @@ const uint8_t sm1_25519[32] = {
0xa7,0xd7,0xfb,0x3d,0x99,0x00,0x4d,0x2b, 0xa7,0xd7,0xfb,0x3d,0x99,0x00,0x4d,0x2b,
0x0b,0xdf,0xc1,0x4f,0x80,0x24,0x83,0x2b 0x0b,0xdf,0xc1,0x4f,0x80,0x24,0x83,0x2b
}; };
template<> const Block Tests<IsoEd25519>::sqrt_minus_one(sm1_25519,32);
template<> const Block Tests<Ristretto>::sqrt_minus_one(sm1_25519,32);


template<> const Block Tests<Ed448Goldilocks>::minus_sqrt_minus_one(NULL,0); template<> const Block Tests<Ed448Goldilocks>::minus_sqrt_minus_one(NULL,0);
const uint8_t msm1_25519[32] = { const uint8_t msm1_25519[32] = {
@@ -62,7 +62,7 @@ const uint8_t msm1_25519[32] = {
0x58,0x28,0x04,0xc2,0x66,0xff,0xb2,0xd4, 0x58,0x28,0x04,0xc2,0x66,0xff,0xb2,0xd4,
0xf4,0x20,0x3e,0xb0,0x7f,0xdb,0x7c,0x54 0xf4,0x20,0x3e,0xb0,0x7f,0xdb,0x7c,0x54
}; };
template<> const Block Tests<IsoEd25519>::minus_sqrt_minus_one(msm1_25519,32);
template<> const Block Tests<Ristretto>::minus_sqrt_minus_one(msm1_25519,32);


const uint8_t elli_patho_448[56] = { const uint8_t elli_patho_448[56] = {
0x14,0xf0,0x70,0x58,0x41,0xc7,0xf9,0xa5, 0x14,0xf0,0x70,0x58,0x41,0xc7,0xf9,0xa5,
@@ -74,7 +74,7 @@ const uint8_t elli_patho_448[56] = {
0x86,0xa9,0x2e,0xc9,0x17,0x68,0x9b,0x20 0x86,0xa9,0x2e,0xc9,0x17,0x68,0x9b,0x20
}; };
template<> const Block Tests<Ed448Goldilocks>::elli_patho(elli_patho_448,56); template<> const Block Tests<Ed448Goldilocks>::elli_patho(elli_patho_448,56);
template<> const Block Tests<IsoEd25519>::elli_patho(NULL,0);
template<> const Block Tests<Ristretto>::elli_patho(NULL,0);


/* EdDSA test vectors */ /* EdDSA test vectors */
const uint8_t ed448_eddsa_sk[][57] = {{ const uint8_t ed448_eddsa_sk[][57] = {{
@@ -481,7 +481,7 @@ const uint8_t ed25519_eddsa_sig[][64] = {{
0x91,0xc2,0x04,0x3d,0x4e,0xb3,0xe9,0x0d 0x91,0xc2,0x04,0x3d,0x4e,0xb3,0xe9,0x0d
}}; }};


template<> const bool Tests<IsoEd25519>::eddsa_prehashed[] = {
template<> const bool Tests<Ristretto>::eddsa_prehashed[] = {
false, false,
false, false,
false, false,
@@ -489,7 +489,7 @@ template<> const bool Tests<IsoEd25519>::eddsa_prehashed[] = {
false, false,
false false
}; };
template<> const Block Tests<IsoEd25519>::eddsa_sk[] = {
template<> const Block Tests<Ristretto>::eddsa_sk[] = {
Block(ed25519_eddsa_sk[0],32), Block(ed25519_eddsa_sk[0],32),
Block(ed25519_eddsa_sk[1],32), Block(ed25519_eddsa_sk[1],32),
Block(ed25519_eddsa_sk[2],32), Block(ed25519_eddsa_sk[2],32),
@@ -498,7 +498,7 @@ template<> const Block Tests<IsoEd25519>::eddsa_sk[] = {
Block(ed25519_eddsa_sk[4],32), Block(ed25519_eddsa_sk[4],32),
Block(NULL,0) Block(NULL,0)
}; };
template<> const Block Tests<IsoEd25519>::eddsa_pk[] = {
template<> const Block Tests<Ristretto>::eddsa_pk[] = {
Block(ed25519_eddsa_pk[0],32), Block(ed25519_eddsa_pk[0],32),
Block(ed25519_eddsa_pk[1],32), Block(ed25519_eddsa_pk[1],32),
Block(ed25519_eddsa_pk[2],32), Block(ed25519_eddsa_pk[2],32),
@@ -506,15 +506,15 @@ template<> const Block Tests<IsoEd25519>::eddsa_pk[] = {
Block(ed25519_eddsa_pk[4],32), Block(ed25519_eddsa_pk[4],32),
Block(ed25519_eddsa_pk[4],32) Block(ed25519_eddsa_pk[4],32)
}; };
template<> const Block Tests<IsoEd25519>::eddsa_context[] = {
EdDSA<IsoEd25519>::NO_CONTEXT(),
EdDSA<IsoEd25519>::NO_CONTEXT(),
EdDSA<IsoEd25519>::NO_CONTEXT(),
template<> const Block Tests<Ristretto>::eddsa_context[] = {
EdDSA<Ristretto>::NO_CONTEXT(),
EdDSA<Ristretto>::NO_CONTEXT(),
EdDSA<Ristretto>::NO_CONTEXT(),
Block(NULL,0), Block(NULL,0),
Block(ed25519_eddsa_context[0],3), Block(ed25519_eddsa_context[0],3),
Block(ed25519_eddsa_context[1],3) Block(ed25519_eddsa_context[1],3)
}; };
template<> const Block Tests<IsoEd25519>::eddsa_message[] = {
template<> const Block Tests<Ristretto>::eddsa_message[] = {
Block(ed25519_eddsa_message[0],0), Block(ed25519_eddsa_message[0],0),
Block(ed25519_eddsa_message[1],1), Block(ed25519_eddsa_message[1],1),
Block(ed25519_eddsa_message[2],2), Block(ed25519_eddsa_message[2],2),
@@ -522,7 +522,7 @@ template<> const Block Tests<IsoEd25519>::eddsa_message[] = {
Block(ed25519_eddsa_message[4],16), Block(ed25519_eddsa_message[4],16),
Block(ed25519_eddsa_message[4],16) Block(ed25519_eddsa_message[4],16)
}; };
template<> const Block Tests<IsoEd25519>::eddsa_sig[] = {
template<> const Block Tests<Ristretto>::eddsa_sig[] = {
Block(ed25519_eddsa_sig[0],64), Block(ed25519_eddsa_sig[0],64),
Block(ed25519_eddsa_sig[1],64), Block(ed25519_eddsa_sig[1],64),
Block(ed25519_eddsa_sig[2],64), Block(ed25519_eddsa_sig[2],64),


Loading…
Cancel
Save