Skip to main content
Version: v2.x

Minimal Anti Collusion Infrastructure (MACI) v2.5.0 / genRandomBabyJubValue

Function: genRandomBabyJubValue()

genRandomBabyJubValue(): bigint

Returns a BabyJub-compatible random value. We create it by first generating a random value (initially 256 bits large) modulo the snark field size as described in EIP197. This results in a key size of roughly 253 bits and no more than 254 bits. To prevent modulo bias, we then use this efficient algorithm: http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/libc/crypt/arc4random_uniform.c

Returns

bigint

A BabyJub-compatible random value.

Defined in

packages/crypto/ts/babyjub.ts:115