Loading...
Searching...
No Matches
decaf::Ed448Goldilocks::Scalar Class Reference

A scalar modulo the curve order. More...

`#include <point_448.hxx>`

Inheritance diagram for decaf::Ed448Goldilocks::Scalar:

## Public Types

typedef decaf_448_scalar_t | Wrapped
| wrapped C type

## Public Member Functions

| Scalar (uint64_t w) DECAF_NOEXCEPT
| Set to an unsigned word.
| Scalar (int64_t w) DECAF_NOEXCEPT
| Set to a signed word.
| Scalar (unsigned int w) DECAF_NOEXCEPT
| Set to an unsigned word.
| Scalar (int w) DECAF_NOEXCEPT
| Set to a signed word.
| Scalar (Rng &rng) DECAF_NOEXCEPT
| Construct from RNG.
| Scalar (const Wrapped &t=decaf_448_scalar_zero) DECAF_NOEXCEPT
| Construct from decaf_scalar_t object.
| Scalar (const Scalar &x) DECAF_NOEXCEPT
| Copy constructor.
| Scalar (const Block &buffer) DECAF_NOEXCEPT
| Construct from arbitrary-length little-endian byte sequence.
size_t | ser_size () const DECAF_NOEXCEPT
| Serializable instance.
void | serialize_into (unsigned char *buffer) const DECAF_NOEXCEPT
| Serializable instance.
Scalar & | operator= (const Scalar &x) DECAF_NOEXCEPT
| Assignment.
Scalar & | operator= (uint64_t w) DECAF_NOEXCEPT
| Assign from unsigned 64-bit integer.
Scalar & | operator= (int64_t w) DECAF_NOEXCEPT
| Assign from signed int.
Scalar & | operator= (unsigned int w) DECAF_NOEXCEPT
| Assign from unsigned int.
Scalar & | operator= (int w) DECAF_NOEXCEPT
| Assign from signed int.
| ~Scalar () DECAF_NOEXCEPT
| Destructor securely zeorizes the scalar.
Scalar & | operator= (const Block &bl) DECAF_NOEXCEPT
| Assign from arbitrary-length little-endian byte sequence in a Block.
Scalar | operator+ (const Scalar &q) const DECAF_NOEXCEPT
| Add.
Scalar & | operator+= (const Scalar &q) DECAF_NOEXCEPT
| Add to this.
Scalar | operator- (const Scalar &q) const DECAF_NOEXCEPT
| Subtract.
Scalar & | operator-= (const Scalar &q) DECAF_NOEXCEPT
| Subtract from this.
Scalar | operator* (const Scalar &q) const DECAF_NOEXCEPT
| Multiply.
Scalar & | operator*= (const Scalar &q) DECAF_NOEXCEPT
| Multiply into this.
Scalar | operator- () const DECAF_NOEXCEPT
| Negate.
Scalar | inverse () const
| Return 1/this.
decaf_error_t DECAF_WARN_UNUSED | inverse_noexcept (Scalar &r) const DECAF_NOEXCEPT
| Invert with Fermat's Little Theorem (slow!).
Scalar | operator/ (const Scalar &q) const
| Return this/q.
Scalar & | operator/= (const Scalar &q)
| Set this to this/q.
Scalar | half () const
| Return half this scalar.
bool | operator!= (const Scalar &q) const DECAF_NOEXCEPT
| Compare in constant time.
bool | operator== (const Scalar &q) const DECAF_NOEXCEPT
| Compare in constant time.
Point | operator* (const Point &q) const DECAF_NOEXCEPT
| Scalarmul with scalar on left.
Point | operator* (const Precomputed &q) const DECAF_NOEXCEPT
| Scalarmul-precomputed with scalar on left.
SecureBuffer | direct_scalarmul (const FixedBlock< SER_BYTES > &in, decaf_bool_t allow_identity=DECAF_FALSE, decaf_bool_t short_circuit=DECAF_TRUE) const
| Direct scalar multiplication.
decaf_error_t DECAF_WARN_UNUSED | direct_scalarmul_noexcept (FixedBuffer< SER_BYTES > &out, const FixedBlock< SER_BYTES > &in, decaf_bool_t allow_identity=DECAF_FALSE, decaf_bool_t short_circuit=DECAF_TRUE) const DECAF_NOEXCEPT
| Direct scalar multiplication.
Public Member Functions inherited from decaf::Serializable< Scalar >
size_t | ser_size () const DECAF_NOEXCEPT
| Return the number of bytes needed to serialize this object.
void | serialize_into (unsigned char *buf) const DECAF_NOEXCEPT
| Serialize this object into a buffer.
SecureBuffer | serialize () const
| Serialize this object into a SecureBuffer and return it.

## Static Public Member Functions

static decaf_error_t DECAF_WARN_UNUSED | decode (Scalar &sc, const FixedBlock< SER_BYTES > buffer) DECAF_NOEXCEPT
| Decode from correct-length little-endian byte sequence.

## Public Attributes

Wrapped | s
| access to the underlying scalar object

## Static Public Attributes

static const size_t | SER_BYTES = DECAF_448_SCALAR_BYTES
| Size of a serialized element.

## Detailed Description

A scalar modulo the curve order.

Supports the usual arithmetic operations, all in constant time.

## Member Function Documentation

## decode()

static decaf_error_t DECAF_WARN_UNUSED decaf::Ed448Goldilocks::Scalar::decode | ( | Scalar & | sc,
|  | const FixedBlock< SER_BYTES > | buffer
| ) |  |

inline static

Decode from correct-length little-endian byte sequence.

Returns
  DECAF_FAILURE if the scalar is greater than or equal to the group order q.

## direct_scalarmul()

SecureBuffer decaf::Ed448Goldilocks::Scalar::direct_scalarmul | ( | const FixedBlock< SER_BYTES > & | in,
|  | decaf_bool_t | allow_identity = `DECAF_FALSE`,
|  | decaf_bool_t | short_circuit = `DECAF_TRUE`
| ) |  | const

inline

Direct scalar multiplication.

Exceptions

  CryptoException | if the input didn't decode.

## half()

Scalar decaf::Ed448Goldilocks::Scalar::half | ( |  | ) | const

inline

Return half this scalar.

Much faster than /2.

## inverse()

Scalar decaf::Ed448Goldilocks::Scalar::inverse | ( |  | ) | const

inline

Return 1/this.

Exceptions

  CryptoException | if this is 0.

## inverse_noexcept()

decaf_error_t DECAF_WARN_UNUSED decaf::Ed448Goldilocks::Scalar::inverse_noexcept | ( | Scalar & | r | ) | const

inline

Invert with Fermat's Little Theorem (slow!).

If *this == 0, set r=0 and return DECAF_FAILURE.

## operator/()

Scalar decaf::Ed448Goldilocks::Scalar::operator/ | ( | const Scalar & | q | ) | const

inline

Return this/q.

Exceptions

  CryptoException | if q == 0.

## operator/=()

Scalar & decaf::Ed448Goldilocks::Scalar::operator/= | ( | const Scalar & | q | ) |

inline

Set this to this/q.

Exceptions

  CryptoException | if q == 0.

The documentation for this class was generated from the following file:

- src/GENERATED/include/decaf/point_448.hxx