latest.ipv8.attestation.wallet.pengbaorange.boudot

Implementation of proofs for checking commitment equality and if a commitment is a square (“Efficient Proofs that a Committed NumberLies in an Interval” by F. Boudot).

Modified for use with range proofs (“An efficient range proof scheme.” by K. Peng and F. Bao).

Module Contents

Classes

EL

Proof that two commitments hide the same secret.

SQR

Proof that a committed number is a square.

Functions

secure_randint(→ int)

Generate a secure random integer.

_sipack(→ bytes)

Pack a list of up to 8 ints to a bytes string, prepended with a byte for which each bit specifies if the packed

_siunpack(→ tuple[Iterator[int], bytes])

Unpack a given number of integer values from a buffer, packed with _sipack().

latest.ipv8.attestation.wallet.pengbaorange.boudot.secure_randint(nmin: int, nmax: int) int

Generate a secure random integer.

latest.ipv8.attestation.wallet.pengbaorange.boudot._sipack(*n: int) bytes

Pack a list of up to 8 ints to a bytes string, prepended with a byte for which each bit specifies if the packed int was negative.

latest.ipv8.attestation.wallet.pengbaorange.boudot._siunpack(buf: bytes, amount: int) tuple[Iterator[int], bytes]

Unpack a given number of integer values from a buffer, packed with _sipack().

class latest.ipv8.attestation.wallet.pengbaorange.boudot.EL(c: int, D: int, D1: int, D2: int)

Proof that two commitments hide the same secret.

classmethod create(x: int, r1: int, r2: int, g1: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h1: latest.ipv8.attestation.wallet.primitives.value.FP2Value, g2: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h2: latest.ipv8.attestation.wallet.primitives.value.FP2Value, b: int, bitspace: int, t: int = 80, l: int = 40) EL

Create a new commitment that allows one to prove knowledge of secret integers x, r1 and r2.

check(g1: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h1: latest.ipv8.attestation.wallet.primitives.value.FP2Value, g2: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h2: latest.ipv8.attestation.wallet.primitives.value.FP2Value, y1: latest.ipv8.attestation.wallet.primitives.value.FP2Value, y2: latest.ipv8.attestation.wallet.primitives.value.FP2Value) bool

Check for equality with another commitment.

serialize() bytes

Convert this commitment to bytes.

classmethod unserialize(s: bytes) tuple[EL, bytes]

Convert bytes to a commitment.

__eq__(other: object) bool

Check if this object is equal to another object.

__hash__() int

Get the hash of this object. Always 6976 to enforce a “heavy” equality check.

__str__() str

Stringify this EL for printing.

class latest.ipv8.attestation.wallet.pengbaorange.boudot.SQR(F: latest.ipv8.attestation.wallet.primitives.value.FP2Value, el: EL)

Proof that a committed number is a square.

classmethod create(x: int, r1: int, g: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h: latest.ipv8.attestation.wallet.primitives.value.FP2Value, b: int, bitspace: int) SQR

Create a new commitment that allows one to prove that the committed integer x is a square.

check(g: latest.ipv8.attestation.wallet.primitives.value.FP2Value, h: latest.ipv8.attestation.wallet.primitives.value.FP2Value, y: latest.ipv8.attestation.wallet.primitives.value.FP2Value) bool

Check for a committed square.

serialize() bytes

Convert this commitment to bytes.

classmethod unserialize(s: bytes) tuple[SQR, bytes]

Convert bytes to a commitment.

__eq__(other: object) bool

Check if this object is equal to another object.

__hash__() int

Get the hash of this object. Always 838182 to enforce a “heavy” equality check.

__str__() str

Stringify this EL for printing.