RangeProof

class blsct.RangeProof(amounts: list[int], nonce: Point, message: str, token_id: TokenId | None = None)

Represents a (possibly aggregated) range proof for one or more confidential transaction amounts.

>>> from blsct import AmountRecoveryReq, AmountRecoveryRes, Point, RangeProof, TokenId
>>> nonce = Point()
>>> token_id = TokenId()
>>> rp = RangeProof([456], nonce, 'navio', token_id)
>>> RangeProof.verify_proofs([rp])
True
>>> req = AmountRecoveryReq(rp, nonce)
>>> res = RangeProof.recover_amounts([req])
0: AmtRecoveryRes(is_succ=True, amount=456, message='navio')
>>> rp.get_A()
Point(a2fb420771db27ad...)
>>> rp.get_A_wip()
Point(a110e82e7ce9db7b...)
>>> rp.get_B()
Point(b20c77bdcf884cc9...)
>>> rp.get_r_prime()
Scalar(2edf3c0ca70d395fda7c809776a3328824a5fc29bd6261afd7e03e9ab952a31b)
>>> rp.get_s_prime()
Scalar(17fe26b25aeb9e2a24dcb257d308f27e57ab4fe6b852bead0259b8e0e4b9abe7)
>>> rp.get_delta_prime()
Scalar(1bc93e6b42fb582f51ba0cd51d64ca2b85cebd15cb8a5c84a1df16f0c6b13cea)
>>> rp.get_alpha_hat()
Scalar(1c1eaca43fbaf1ec5f1304ec56d0e29e639a5189a61a7bd752e1d449702c463b)
>>> rp.get_tau_x()
Scalar(5e07a8b9254fab11399f42d5695c9bfe3d00bc6478c5a480442cfac6567ef2ee)
>>> ser = rp.serialize()
>>> deser = RangeProof.deserialize(ser)
>>> ser == deser.serialize()
True
classmethod deserialize(hex: str) → Self

Deserialize the RangeProof from a hexadecimal string

get_A() → Point

Get the range proof element A.

get_A_wip() → Point

Get the range proof element A_wip.

get_B() → Point

Get the range proof element B.

get_alpha_hat() → Scalar

Get the range proof element alpha hat.

get_delta_prime() → Scalar

Get the range proof element delta_prime.

get_r_prime() → Scalar

Get the range proof element r_prime.

get_s_prime() → Scalar

Get the range proof element s_prime.

get_tau_x() → Scalar

Get the range proof element tau_x.

static recover_amounts(reqs: list[AmountRecoveryReq]) → list[AmountRecoveryRes]

Recover the amount from each given single-amount range proof. The results may include failures.

serialize() → str

Serialize the RangeProof to a hexadecimal string

static verify_proofs(proofs: list[TypeAliasForwardRef('blsct.RangeProof')]) → bool

Verify a list of range proofs.