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:- Hash message to field elements using hash_to_field (external)
- Map field elements to curve points using this precompile (0x12)
- Clear cofactor to ensure point is in correct subgroup (if needed)
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
- Must be < field modulus p
- Big-endian encoding
- Left-padded with zeros to 64 bytes
- All values 0 to p-1 are valid inputs
Output Format
- 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
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:- Map Fp element to point on isogenous curve E’
- Evaluate isogeny map to get point on target curve E
- Result is valid G1 point
Hash-to-Curve Standards
This precompile implements the mapping function from:- RFC: draft-irtf-cfrg-hash-to-curve
- Suite: BLS12381G1_XMD:SHA-256_SSWU_RO_
- Method: Simplified Shallue-van de Woestijne-Ulas (SSWU)
- Use hash_to_field to get two field elements u₀, u₁
- Map both to curve: Q₀ = map(u₀), Q₁ = map(u₁)
- Add points: Q = Q₀ + Q₁
- Clear cofactor: P = clear_cofactor(Q)
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

