2.12.ipv8.attestation.wallet.primitives.boneh

Implementation of the Boneh 2-DNF scheme (“Evaluating 2-DNF Formulas on Ciphertexts” by Boneh et al.).

Module Contents

Functions

2.12.ipv8.attestation.wallet.primitives.boneh.generate_prime(n: int) int
Generate p = l * n - 1 such that:
  • p is “prime”

  • p mod 3 = 2

  • l is an as small as possible positive integer.

2.12.ipv8.attestation.wallet.primitives.boneh.bilinear_group(n: int, p: int, g1x: int, g1y: int, g2x: int, g2y: int) 2.12.ipv8.attestation.wallet.primitives.value.FP2Value

Generate a bilinear group for two generators.

2.12.ipv8.attestation.wallet.primitives.boneh.get_random_exponentiation(p: 2.12.ipv8.attestation.wallet.primitives.value.FP2Value, n: int) 2.12.ipv8.attestation.wallet.primitives.value.FP2Value

Create a random exponentiation of p in message space n.

2.12.ipv8.attestation.wallet.primitives.boneh.get_random_base(n: int) tuple[int, int]

Create a generator for the EC.

2.12.ipv8.attestation.wallet.primitives.boneh.is_good_wp(n: int, wp: 2.12.ipv8.attestation.wallet.primitives.value.FP2Value) bool

A good pairing is not 0 and has order n.

2.12.ipv8.attestation.wallet.primitives.boneh.get_good_wp(n: int, p: int | None = None) tuple[int, 2.12.ipv8.attestation.wallet.primitives.value.FP2Value]

Instead of inspecting torsion points and checking for co-primality: just brute force generate pairings until we get a good one.

Returns:

modulus, weilparing.

2.12.ipv8.attestation.wallet.primitives.boneh.generate_primes(key_size: int = 128) tuple[int, int]

Generate some primes. Key size in bits.

2.12.ipv8.attestation.wallet.primitives.boneh.generate_keypair(key_size: int = 32) tuple[2.12.ipv8.attestation.wallet.primitives.structs.BonehPublicKey, 2.12.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey]

Generate a keypair for a certain prime bit space.

2.12.ipv8.attestation.wallet.primitives.boneh.encode(pubkey: 2.12.ipv8.attestation.wallet.primitives.structs.BonehPublicKey, m: int) 2.12.ipv8.attestation.wallet.primitives.value.FP2Value

Encode a message m given a public key.

2.12.ipv8.attestation.wallet.primitives.boneh.decode(privkey: 2.12.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey, msgspace: list[int], c: 2.12.ipv8.attestation.wallet.primitives.value.FP2Value) int | None

Decode a ciphertext c given a private key and the possible source messages.