Skip to content

Finite field arithmetic #18

@jedisct1

Description

@jedisct1

We need to expose basic arithmetic over finite fields and common operations on EC points in our API.

This is required to implement PAKEs and threshold signatures among things that the module doesn’t implement directly.

Operations over elliptic curves and quotient groups

Minimal set of operations we probably need:

  • Hash-to-group (once the irtf-cfrg-hash-to-curve draft settles)
  • Map to (optional)/from uniform random strings. This differs from the hash-to-group operation by the optional presence of an inverse map (e.g. Elligator)
  • Element verification: for an EC point, check the curve equation and that the point is on the main subgroup <— do we actually need this, or should we make it impossible to create an invalid group element?
  • Random group element
  • Addition, subtraction
  • Import, export
  • Scalar multiplication <— What about clamping? How do we go from this to a standard x25519 key? Shall curve25519 and curve25519-unclamped be exposed as different groups? Should scalar multiplication be clamped by default, and clamping can be disabled by setting a property on the point object? Should we expect applications to clamp themselves? Should a keypair import function clamp and recompute the public key?
  • Fixed base scalar multiplication

We also need to add functions to create public and secret keys (for DH and signing) from group elements.

Operations on scalars

  • Import, export
  • Addition, subtraction, multiplication, squaring, exponentiation, inversion, negation
  • Comparison, conditional move
  • Get 0, 1.

We probably don’t want a general bignum library here, and only support field sizes relevant to the curves we support. This will allow us to use optimized and formally verified (e.g. generated by fiat-crypto or HACL*) implementations.

Should that be in another module?

These operations can be in a different module.

If we go that route, how can a key pair be created from a handle coming from that other module?

Do we make a serialized representation the only way to import a key?

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions