purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
curve.cpp File Reference

Compiled elliptic-curve helpers, parameters, and key encoding logic for Purify. More...

#include "purify/curve.hpp"
#include <algorithm>
#include "curve.h"

Go to the source code of this file.

Namespaces

namespace  purify
 

Functions

Bytes purify::bytes_from_ascii (std::string_view input)
 Encodes an ASCII string as a byte vector.
 
Bytes purify::operator+ (Bytes lhs, const Bytes &rhs)
 Concatenates two byte vectors.
 
std::uint64_t purify::ceil_div (std::uint64_t lhs, std::uint64_t rhs)
 Computes ceiling division for unsigned 64-bit values.
 
Bytes purify::hmac_sha256 (const Bytes &key, const Bytes &data)
 Computes an HMAC-SHA256 digest using the secp bridge implementation.
 
Bytes purify::hkdf (std::size_t length, const Bytes &ikm, const Bytes &salt={}, const Bytes &info={})
 Expands input key material using HKDF-SHA256.
 
const UInt256purify::prime_p ()
 Returns the Purify base-field modulus.
 
const UInt256purify::order_n1 ()
 Returns the subgroup order for the first curve.
 
const UInt256purify::order_n2 ()
 Returns the subgroup order for the second curve.
 
const UInt256purify::half_n1 ()
 Returns floor(order_n1 / 2).
 
const UInt256purify::half_n2 ()
 Returns floor(order_n2 / 2).
 
const UInt512purify::packed_secret_key_space_size ()
 Returns the size of the packed secret-key encoding space.
 
const UInt512purify::packed_public_key_space_size ()
 Returns the size of the packed public-key encoding space.
 
const UInt320purify::two_p ()
 Returns 2 * prime_p() as a widened integer for hash-to-curve sampling.
 
FieldElement purify::field_a ()
 Returns the shared Weierstrass a coefficient used by Purify.
 
FieldElement purify::field_b ()
 Returns the shared Weierstrass b coefficient used by Purify.
 
FieldElement purify::field_d ()
 Returns the twist factor used to derive the second curve.
 
FieldElement purify::field_di ()
 Returns the inverse of the twist factor in the field.
 
const EllipticCurvepurify::curve1 ()
 Returns the first Purify curve instance.
 
const EllipticCurvepurify::curve2 ()
 Returns the second Purify curve instance.
 
Result< JacobianPointpurify::hash_to_curve (const Bytes &data, const EllipticCurve &curve)
 Hashes arbitrary data onto the supplied curve by rejection sampling x-coordinates.
 
const JacobianPointpurify::generator1 ()
 Returns the fixed generator for the first curve.
 
const JacobianPointpurify::generator2 ()
 Returns the fixed generator for the second curve.
 
bool purify::is_valid_secret_key (const UInt512 &z)
 Returns true when a packed secret is encoded canonically.
 
bool purify::is_valid_public_key (const UInt512 &packed)
 Returns true when a packed public key is encoded canonically.
 
Status purify::validate_secret_key (const UInt512 &z)
 Validates the packed secret-key encoding range.
 
Status purify::validate_public_key (const UInt512 &packed)
 Validates the packed public-key encoding range.
 
Result< std::pair< UInt256, UInt256 > > purify::unpack_secret (const UInt512 &z)
 Splits a packed private key into its two per-curve secret scalars.
 
Result< std::pair< UInt256, UInt256 > > purify::unpack_public (const UInt512 &packed)
 Splits a packed public key into its two x-coordinates.
 
UInt512 purify::pack_public (const UInt256 &x1, const UInt256 &x2)
 Packs two x-coordinates into the reference 512-bit public-key encoding.
 
FieldElement purify::combine (const FieldElement &x1, const FieldElement &x2)
 Applies the Purify curve-combination map to two x-coordinates.
 
Result< std::vector< int > > purify::key_to_bits (UInt256 n, const UInt256 &max_value)
 Encodes a scalar into the signed 3-bit window bit schedule used by the circuit.