ECVRF Code Utils#

pragma_sdk.common.randomness.randomness_utils.ecvrf_proof_to_hash(pi_string)[source]#
Input:

pi_string - VRF proof, octet string of length ptLen+n+qLen (80) bytes

Output:

(“VALID”, beta_string) where beta_string is the VRF hash output, octet string of length hLen (64) bytes, or (“INVALID”, []) upon failure

pragma_sdk.common.randomness.randomness_utils.ecvrf_prove(secret_key, alpha_string)[source]#
Input:

secret_key - VRF private key (32 bytes) alpha_string - input alpha, an octet string

Output:

(“VALID”, pi_string) - where pi_string is the VRF proof, octet string of length ptLen+n+qLen (80) bytes, or (“INVALID”, []) upon failure

pragma_sdk.common.randomness.randomness_utils.ecvrf_verify(y, pi_string, alpha_string) -> (<class 'str'>, <class 'list'>)[source]#
Input:

y - public key, an EC point as bytes pi_string - VRF proof, octet string of length ptLen+n+qLen (80) bytes alpha_string - VRF input, octet string

Output:

(“VALID”, beta_string), where beta_string is the VRF hash output, octet string of length hLen (64) bytes; or (“INVALID”, []) upon failure

pragma_sdk.common.randomness.randomness_utils.get_public_key(secret_key: str) str[source]#

Calculate and return the public_key as an encoded point string (bytes)

Randomness Utils#

pragma_sdk.common.randomness.utils.create_randomness(secret_key: str, seed: int) Tuple[str, str, str][source]#
pragma_sdk.common.randomness.utils.felt_to_secret_key(felt: int) bytes[source]#
pragma_sdk.common.randomness.utils.make_secret_key() bytes[source]#
pragma_sdk.common.randomness.utils.uint256_to_2_128(num: int) Tuple[int, int][source]#
pragma_sdk.common.randomness.utils.verify_randomness(public_key: str, proof_: str, seed: int) str[source]#