3.0.ipv8.attestation.wallet.pengbaorange.structs ================================================ .. py:module:: 3.0.ipv8.attestation.wallet.pengbaorange.structs Classes ------- .. autoapisummary:: 3.0.ipv8.attestation.wallet.pengbaorange.structs.PengBaoCommitment 3.0.ipv8.attestation.wallet.pengbaorange.structs.PengBaoCommitmentPrivate 3.0.ipv8.attestation.wallet.pengbaorange.structs.PengBaoPublicData 3.0.ipv8.attestation.wallet.pengbaorange.structs.PengBaoAttestation Functions --------- .. autoapisummary:: 3.0.ipv8.attestation.wallet.pengbaorange.structs._serialize_fp2value 3.0.ipv8.attestation.wallet.pengbaorange.structs._unserialize_fp2value Module Contents --------------- .. py:function:: _serialize_fp2value(value: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value) -> bytes Convert an FP2Value to bytes. .. py:function:: _unserialize_fp2value(mod: int, value: bytes) -> tuple[3.0.ipv8.attestation.wallet.primitives.value.FP2Value, bytes] Decode serialized bytes back into an FP2Value of the given modulus. .. py:class:: PengBaoCommitment(c: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, c1: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, c2: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, ca: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, ca1: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, ca2: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, ca3: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value, caa: 3.0.ipv8.attestation.wallet.primitives.value.FP2Value) The proof structure that a commitment hides a value within a certain range. .. py:attribute:: c .. py:attribute:: c1 .. py:attribute:: c2 .. py:attribute:: ca .. py:attribute:: ca1 .. py:attribute:: ca2 .. py:attribute:: ca3 .. py:attribute:: caa .. py:method:: serialize() -> bytes Convert this commitment to bytes. .. py:method:: unserialize(s: bytes) -> tuple[PengBaoCommitment, bytes] :classmethod: Convert bytes to a commitment. .. py:class:: PengBaoCommitmentPrivate(m1: int, m2: int, m3: int, r1: int, r2: int, r3: int) Private part of the PengBaoCommitment. .. py:attribute:: MSGSPACE :type: list[int] .. py:attribute:: m1 .. py:attribute:: m2 .. py:attribute:: m3 .. py:attribute:: r1 .. py:attribute:: r2 .. py:attribute:: r3 .. py:method:: 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). :param s: the challenge value s :type s: int :param t: the challenge value t :type t: int :return: the challenge response :rtype: int .. py:method:: serialize() -> bytes Convert this commitment to bytes. .. py:method:: unserialize(s: bytes) -> tuple[PengBaoCommitmentPrivate, bytes] :classmethod: Convert bytes to a commitment. .. py:method:: encode(PK: 3.0.ipv8.attestation.wallet.primitives.structs.BonehPublicKey) -> bytes Serialize and encode using a given public key. .. py:method:: decode(SK: 3.0.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey, s: bytes) -> PengBaoCommitmentPrivate :classmethod: Decode an encoded PengBaoCommitmentPrivate using a secret key. .. py:class:: PengBaoPublicData(PK: 3.0.ipv8.attestation.wallet.primitives.structs.BonehPublicKey, bitspace: int, commitment: PengBaoCommitment, el: 3.0.ipv8.attestation.wallet.pengbaorange.boudot.EL, sqr1: 3.0.ipv8.attestation.wallet.pengbaorange.boudot.SQR, sqr2: 3.0.ipv8.attestation.wallet.pengbaorange.boudot.SQR) Public data required to verify a Peng Bao proof. .. py:attribute:: PK .. py:attribute:: bitspace .. py:attribute:: commitment .. py:attribute:: el .. py:attribute:: sqr1 .. py:attribute:: sqr2 .. py:method:: 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. .. py:method:: serialize() -> bytes Serialize this Attestation to a string. :return: the serialized form of this attestation :rtype: str .. py:method:: unserialize(s: bytes) -> tuple[PengBaoPublicData, bytes] :classmethod: Given a string, create an Attestation object. :param s: the string to unserialize :type s: str :return: the attestation object :rtype: PengBaoPublicData .. py:class:: PengBaoAttestation(publicdata: PengBaoPublicData, privatedata: PengBaoCommitmentPrivate | None, id_format: str | None = None) Bases: :py:obj:`3.0.ipv8.attestation.identity_formats.Attestation` An attestation for a Peng Bao range proof. .. py:attribute:: publicdata .. py:attribute:: privatedata .. py:attribute:: id_format .. py:attribute:: PK .. py:method:: serialize() -> bytes Serialize this Attestation to a string. :return: the serialized form of this attestation :rtype: str .. py:method:: serialize_private(PK: 3.0.ipv8.attestation.wallet.primitives.structs.BonehPublicKey) -> bytes Serialize this Attestation to a string, include shared secrets (not to be published!). :param PK: the public key to encode for :return: the serialized form of this attestation :rtype: str .. py:method:: unserialize(s: bytes, id_format: str | None = None) -> PengBaoAttestation :classmethod: Given a string, create an Attestation object. :param s: the string to unserialize :type s: str :param id_format: the identity format :type id_format: str :return: the attestation object :rtype: Attestation .. py:method:: unserialize_private(SK: 3.0.ipv8.attestation.wallet.primitives.structs.BonehPrivateKey, s: bytes, id_format: str | None = None) -> PengBaoAttestation :classmethod: Given a string, create an Attestation object. The input contains shared secrets not to be published. :param SK: the secret key to decode with :param s: the string to unserialize :type s: str :param id_format: the identity format :type id_format: str :return: the attestation object :rtype: Attestation