Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

Overview

Address: 0x0000000000000000000000000000000000000012 Introduced: Prague (EIP-2537) EIP: EIP-2537 The BLS12-381 Map Fp to G1 precompile maps a field element from the base field Fp to a point on the G1 curve. This is a core building block for hash-to-curve operations, enabling deterministic point generation for BLS signatures, VRFs, and other cryptographic protocols. Hash-to-curve provides a way to hash arbitrary messages to curve points in a way that is:
  • Deterministic: Same input always produces same output
  • Uniform: Output distribution is indistinguishable from random
  • One-way: Cannot reverse the mapping
  • Collision-resistant: Hard to find different inputs mapping to same point

Hash-to-Curve Overview

The complete hash-to-curve process typically involves:
  1. Hash message to field elements using hash_to_field (external)
  2. Map field elements to curve points using this precompile (0x12)
  3. Clear cofactor to ensure point is in correct subgroup (if needed)
This precompile implements step 2: the deterministic mapping from a field element to a G1 curve point.

Gas Cost

Fixed cost: 5,500 gas (constant, independent of input) Much cheaper than elliptic curve operations since it’s a single mapping operation without scalar multiplication.

Input Format

Total input length: 64 bytes (exactly) Field element constraints:
  • Must be < field modulus p
  • Big-endian encoding
  • Left-padded with zeros to 64 bytes
  • All values 0 to p-1 are valid inputs
BLS12-381 base field modulus p:
(381-bit prime, ~48 bytes, padded to 64)

Output Format

Total output length: 128 bytes (G1 point in uncompressed form) Output is always a valid G1 point on the curve. The mapping ensures:
  • Point is on curve: y² = x³ + 4
  • Point is in correct subgroup (after cofactor clearing if protocol requires)
  • Mapping is deterministic and injective

Usage Examples

TypeScript

Zig

Error Conditions

  • Out of gas: Gas limit less than 5,500
  • Invalid input length: Input not exactly 64 bytes
  • Field element overflow: Input value >= field modulus p
  • Invalid encoding: Malformed field element
Note: All field elements in range [0, p-1] are valid inputs and will successfully map to G1 points.

Use Cases

BLS Signature Hash-to-Curve

BLS signatures require hashing messages to curve points:

Verifiable Random Functions (VRF)

VRFs use hash-to-curve for deterministic randomness:

Identity-Based Encryption

Map identities (email addresses, etc.) to public keys:

Threshold Cryptography

Deterministic point generation for distributed key generation:

Implementation Details

  • Algorithm: Simplified SWU (Shallue-van de Woestijne-Ulas) map
  • Curve: BLS12-381 G1 over Fp (equation: y² = x³ + 4)
  • Properties: Deterministic, injective (one-to-one), constant-time
  • Zig: Uses blst library implementation via C FFI
  • TypeScript: Uses @noble/curves BLS12-381 hash-to-curve

Simplified SWU Method

The map uses an isogeny-based approach:
  1. Map Fp element to point on isogenous curve E’
  2. Evaluate isogeny map to get point on target curve E
  3. Result is valid G1 point
This provides better distribution properties than older try-and-increment methods.

Hash-to-Curve Standards

This precompile implements the mapping function from: For complete hash-to-curve:
  1. Use hash_to_field to get two field elements u₀, u₁
  2. Map both to curve: Q₀ = map(u₀), Q₁ = map(u₁)
  3. Add points: Q = Q₀ + Q₁
  4. Clear cofactor: P = clear_cofactor(Q)
This precompile handles step 2. Steps 1, 3, 4 done in application code.

Security Considerations

Constant-Time Execution

The mapping must be constant-time to prevent timing side-channels:
  • No branches based on input value
  • Uniform execution path for all inputs
  • Protects secret keys in signature schemes

Distribution Uniformity

The map produces points with distribution indistinguishable from random:
  • Important for VRF security
  • Prevents bias in cryptographic protocols
  • Two-map approach (u₀, u₁) improves uniformity

Domain Separation

Different protocols should use different domain separation tags:

Comparison with Other Approaches

Try-and-Increment (Legacy)

  • Hash + point validation loop
  • Variable time (security risk)
  • Non-uniform distribution
  • Not recommended

Simplified SWU (This Precompile)

  • Constant time
  • Uniform distribution
  • Standards-compliant
  • Recommended

Test Vectors

Zero Element

Maximum Field Element

Determinism Test