Skip to content

@circom:field.rand

Generate a uniformly random BN254 field element (rejection-sampled, no modulo bias) for secrets, trapdoors and commitment salts.

⚗️ Experimental — available at next.evmcrispr.com.

Returns: number

@circom:field.rand
# Random secret and its Poseidon commitment
set $secret @circom:field.rand()
print "Commitment:" @circom:poseidon($secret)
  • Uses rejection sampling over crypto.getRandomValues, so values are uniform over the field (no modulo bias).
  • Each evaluation produces a fresh value — bind it with set if you need to reuse it.