Module Contents¶
Classes¶
Data encryption key series with automatic (time-based) key rotation |
|
- class autobahn.xbr._seller.KeySeries(api_id, price, interval=None, count=None, on_rotate=None)[source]¶
Bases:
object
Data encryption key series with automatic (time-based) key rotation and key offering (to the XBR market maker).
- property key_id¶
Get current XBR data encryption key ID (of the keys being rotated in a series).
- Returns
Current key ID in key series (16 bytes).
- Return type
- class autobahn.xbr._seller.SimpleSeller(market_maker_adr, seller_key, provider_id=None)[source]¶
Bases:
object
- property public_key¶
This seller delegate public Ethereum key.
- Returns
Ethereum public key of this seller delegate.
- Return type
- log¶
- KeySeries¶
- STATE_NONE = 0¶
- STATE_STARTING = 1¶
- STATE_STARTED = 2¶
- STATE_STOPPING = 3¶
- STATE_STOPPED = 4¶
- add(api_id, prefix, price, interval=None, count=None, categories=None)[source]¶
Add a new (rotating) private encryption key for encrypting data on the given API.
- Parameters
api_id (bytes) – API for which to create a new series of rotating encryption keys.
price (int) – Price in XBR token per key.
interval (int) – Interval (in seconds) after which to auto-rotate the encryption key.
count (int) – Number of encryption operations after which to auto-rotate the encryption key.
- async start(session)[source]¶
Start rotating keys and placing key offers with the XBR market maker.
- Parameters
session (
autobahn.wamp.protocol.ApplicationSession
) – WAMP session over which to communicate with the XBR market maker.
- async balance()[source]¶
Return current (off-chain) balance of paying channel:
amount
: The initial amount with which the paying channel was opened.remaining
: The remaining amount of XBR in the paying channel that can be earned.inflight
: The amount of XBR allocated to sell transactions that are currently processed.
- Returns
Current paying balance.
- Return type
- async wrap(api_id, uri, payload)[source]¶
Encrypt and wrap application payload for a given API and destined for a specific WAMP URI.
- Parameters
- Returns
The encrypted and wrapped application payload: a tuple with
(key_id, serializer, ciphertext)
.- Return type
- close_channel(market_maker_adr, channel_oid, channel_seq, channel_balance, channel_is_final, marketmaker_signature, details=None)[source]¶
Called by a XBR Market Maker to close a paying channel.
- sell(market_maker_adr, buyer_pubkey, key_id, channel_oid, channel_seq, amount, balance, signature, details=None)[source]¶
Called by a XBR Market Maker to buy a data encyption key. The XBR Market Maker here is acting for (triggered by) the XBR buyer delegate.
- Parameters
market_maker_adr (bytes of length 20) – The market maker Ethereum address. The technical buyer is usually the XBR market maker (== the XBR delegate of the XBR market operator).
buyer_pubkey (bytes of length 32) – The buyer delegate Ed25519 public key.
key_id (bytes of length 16) – The UUID of the data encryption key to buy.
channel_oid (bytes of length 16) – The on-chain channel contract address.
channel_seq (int) – Paying channel sequence off-chain transaction number.
amount (bytes) – The amount paid by the XBR Buyer via the XBR Market Maker.
balance (bytes) – Balance remaining in the payment channel (from the market maker to the seller) after successfully buying the key.
signature (bytes of length 65) – Signature over the supplied buying information, using the Ethereum private key of the market maker (which is the delegate of the marker operator).
details (
autobahn.wamp.types.CallDetails
) – Caller details. The call will come from the XBR Market Maker.
- Returns
The data encryption key, itself encrypted to the public key of the original buyer.
- Return type