2.13.ipv8.attestation.wallet.pengbaorange.structs

Module Contents

Classes

Functions

2.13.ipv8.attestation.wallet.pengbaorange.structs._serialize_fp2value(value: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value) bytes

Convert an FP2Value to bytes.

2.13.ipv8.attestation.wallet.pengbaorange.structs._unserialize_fp2value(mod: int, value: bytes) tuple[2.13.ipv8.attestation.wallet.primitives.value.FP2Value, bytes]

Decode serialized bytes back into an FP2Value of the given modulus.

class 2.13.ipv8.attestation.wallet.pengbaorange.structs.PengBaoCommitment(c: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, c1: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, c2: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, ca: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, ca1: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, ca2: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, ca3: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value, caa: 2.13.ipv8.attestation.wallet.primitives.value.FP2Value)

The proof structure that a commitment hides a value within a certain range.

serialize() bytes

Convert this commitment to bytes.

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

Convert bytes to a commitment.

class 2.13.ipv8.attestation.wallet.pengbaorange.structs.PengBaoCommitmentPrivate(m1: int, m2: int, m3: int, r1: int, r2: int, r3: int)

Private part of the PengBaoCommitment.

MSGSPACE: list[int]
generate_response(s: int, t: int) tuple[int, int, int, int]

Given s and t and our private information, generate the appropriate response.

The calling function should make sure s and t are large integers (at least larger than 0).

Parameters:
  • s (int) – the challenge value s

  • t (int) – the challenge value t

Returns:

the challenge response

Return type:

int

serialize() bytes

Convert this commitment to bytes.

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

Convert bytes to a commitment.

encode(PK: 2.13.ipv8.attestation.wallet.primitives.structs.BonehPublicKey) bytes

Serialize and encode using a given public key.

classmethod decode(SK: 2.13.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey, s: bytes) PengBaoCommitmentPrivate

Decode an encoded PengBaoCommitmentPrivate using a secret key.

class 2.13.ipv8.attestation.wallet.pengbaorange.structs.PengBaoPublicData(PK: 2.13.ipv8.attestation.wallet.primitives.structs.BonehPublicKey, bitspace: int, commitment: PengBaoCommitment, el: 2.13.ipv8.attestation.wallet.pengbaorange.boudot.EL, sqr1: 2.13.ipv8.attestation.wallet.pengbaorange.boudot.SQR, sqr2: 2.13.ipv8.attestation.wallet.pengbaorange.boudot.SQR)

Public data required to verify a Peng Bao proof.

check(a: int, b: int, s: int, t: int, x: int, y: int, u: int, v: int) bool

Check whether the given range is correct.

serialize() bytes

Serialize this Attestation to a string.

Returns:

the serialized form of this attestation

Return type:

str

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

Given a string, create an Attestation object.

Parameters:

s (str) – the string to unserialize

Returns:

the attestation object

Return type:

PengBaoPublicData

class 2.13.ipv8.attestation.wallet.pengbaorange.structs.PengBaoAttestation(publicdata: PengBaoPublicData, privatedata: PengBaoCommitmentPrivate | None, id_format: str | None = None)

Bases: 2.13.ipv8.attestation.identity_formats.Attestation

An attestation for a Peng Bao range proof.

serialize() bytes

Serialize this Attestation to a string.

Returns:

the serialized form of this attestation

Return type:

str

serialize_private(PK: 2.13.ipv8.attestation.wallet.primitives.structs.BonehPublicKey) bytes

Serialize this Attestation to a string, include shared secrets (not to be published!).

Parameters:

PK – the public key to encode for

Returns:

the serialized form of this attestation

Return type:

str

classmethod unserialize(s: bytes, id_format: str | None = None) PengBaoAttestation

Given a string, create an Attestation object.

Parameters:
  • s (str) – the string to unserialize

  • id_format (str) – the identity format

Returns:

the attestation object

Return type:

Attestation

classmethod unserialize_private(SK: 2.13.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey, s: bytes, id_format: str | None = None) PengBaoAttestation

Given a string, create an Attestation object. The input contains shared secrets not to be published.

Parameters:
  • SK – the secret key to decode with

  • s (str) – the string to unserialize

  • id_format (str) – the identity format

Returns:

the attestation object

Return type:

Attestation