xoflib package
Module contents
A Python package for the Shake extendable-output functions (XOFs): Shake128, Shake256 and the turbo variants built with pyO3 bindings to the sha3 Rust crate.
- class xoflib.AsconASponge
Bases:
objectAsconASponge implements sponge expansion for the AsconAXof XOF
- read(n)
Read n bytes of data from the AsconAXof XOF
Example:
>>> from xoflib import AsconAXof >>> xof = AsconAXof(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() 'e3d5593d0e08c5a7c6cbf751fb817f0a'
- read_into(buf)
Fill the input buffer with data from the AsconAXof XOF Example:
>>> from xoflib import AsconAXof >>> xof = AsconAXof(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() 'e3d5593d0e08c5a7c6cbf751fb817f0a'
- class xoflib.AsconAXof(input_bytes=None)
Bases:
objectAsconA implements absorption and finalization for the AsconAXof XOF
- absorb(input_bytes)
Absorb input_bytes into the AsconAXof state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import AsconAXof >>> xof = AsconAXof(b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the AsconAXof XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import AsconAXof >>> xof = AsconAXof(b"Some initial data") >>> xof = xof.finalize()
- class xoflib.AsconSponge
Bases:
objectAsconSponge implements sponge expansion for the AsconXof XOF
- read(n)
Read n bytes of data from the AsconXof XOF
Example:
>>> from xoflib import AsconXof >>> xof = AsconXof(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() '202e12280fb6781470016dc067d3b213'
- read_into(buf)
Fill the input buffer with data from the AsconXof XOF Example:
>>> from xoflib import AsconXof >>> xof = AsconXof(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() '202e12280fb6781470016dc067d3b213'
- class xoflib.AsconXof(input_bytes=None)
Bases:
objectAscon implements absorption and finalization for the AsconXof XOF
- absorb(input_bytes)
Absorb input_bytes into the AsconXof state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import AsconXof >>> xof = AsconXof(b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the AsconXof XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import AsconXof >>> xof = AsconXof(b"Some initial data") >>> xof = xof.finalize()
- class xoflib.Blake3(input_bytes=None)
Bases:
objectBlake3Xof implements absorption and finalization for the Blake3 XOF
- absorb(input_bytes)
Absorb input_bytes into the Blake3 state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import Blake3 >>> xof = Blake3(b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the Blake3 XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import Blake3 >>> xof = Blake3(b"Some initial data") >>> xof = xof.finalize()
- class xoflib.Blake3Sponge
Bases:
objectBlake3Sponge implements sponge expansion for the Blake3 XOF
- read(n)
Read n bytes of data from the Blake3 XOF
Example:
>>> from xoflib import Blake3 >>> xof = Blake3(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() '79c528b01f9519031bb3ebfbb4d99ecb'
- read_into(buf)
Fill the input buffer with data from the Blake3 XOF Example:
>>> from xoflib import Blake3 >>> xof = Blake3(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() '79c528b01f9519031bb3ebfbb4d99ecb'
- class xoflib.Shake128(input_bytes=None)
Bases:
objectShaker128 implements absorption and finalization for the Shake128 XOF
- absorb(input_bytes)
Absorb input_bytes into the Shake128 state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import Shake128 >>> xof = Shake128(b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the Shake128 XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import Shake128 >>> xof = Shake128(b"Some initial data") >>> xof = xof.finalize()
- class xoflib.Shake256(input_bytes=None)
Bases:
objectShaker256 implements absorption and finalization for the Shake256 XOF
- absorb(input_bytes)
Absorb input_bytes into the Shake256 state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import Shake256 >>> xof = Shake256(b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the Shake256 XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import Shake256 >>> xof = Shake256(b"Some initial data") >>> xof = xof.finalize()
- class xoflib.Sponge128
Bases:
objectSponge128 implements sponge expansion for the Shake128 XOF
- read(n)
Read n bytes of data from the Shake128 XOF
Example:
>>> from xoflib import Shake128 >>> xof = Shake128(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() '2c67a3c30e75de37d30e3f6d94e05a00'
- read_into(buf)
Fill the input buffer with data from the Shake128 XOF Example:
>>> from xoflib import Shake128 >>> xof = Shake128(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() '2c67a3c30e75de37d30e3f6d94e05a00'
- class xoflib.Sponge256
Bases:
objectSponge256 implements sponge expansion for the Shake256 XOF
- read(n)
Read n bytes of data from the Shake256 XOF
Example:
>>> from xoflib import Shake256 >>> xof = Shake256(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() '82786e027034dccb6f41224c22a227c9'
- read_into(buf)
Fill the input buffer with data from the Shake256 XOF Example:
>>> from xoflib import Shake256 >>> xof = Shake256(b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() '82786e027034dccb6f41224c22a227c9'
- class xoflib.TurboShake128(domain_sep, input_bytes=None)
Bases:
objectTurboShaker128 implements absorption and finalization for the TurboShake128 XOF
- absorb(input_bytes)
Absorb input_bytes into the TurboShake128Core state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import TurboShake128 >>> xof = TurboShake128(1, b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the TurboShake128Core XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import TurboShake128 >>> xof = TurboShake128(1, b"Some initial data") >>> xof = xof.finalize()
- class xoflib.TurboShake256(domain_sep, input_bytes=None)
Bases:
objectTurboShaker256 implements absorption and finalization for the TurboShake256 XOF
- absorb(input_bytes)
Absorb input_bytes into the TurboShake256Core state
Note: this method can be chained, i.e. .absorb().absorb()
Example:
>>> from xoflib import TurboShake256 >>> xof = TurboShake256(1, b"Some initial data") >>> xof.absorb(bytearray(b"Ooh just a little bit more data"))
- finalize()
Finalize the TurboShake256Core XOF into a sponge for expansion
This method also resets the state, allowing more data to be absorbed. Example:
>>> from xoflib import TurboShake256 >>> xof = TurboShake256(1, b"Some initial data") >>> xof = xof.finalize()
- class xoflib.TurboSponge128
Bases:
objectTurboSponge128 implements sponge expansion for the TurboShake128 XOF
- read(n)
Read n bytes of data from the TurboShake128 XOF
Example:
>>> from xoflib import TurboShake128 >>> xof = TurboShake128(1, b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() 'b6be317e80aa741b9f0ac9330d584506'
- read_into(buf)
Fill the input buffer with data from the TurboShake128 XOF Example:
>>> from xoflib import TurboShake128 >>> xof = TurboShake128(1, b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() 'b6be317e80aa741b9f0ac9330d584506'
- class xoflib.TurboSponge256
Bases:
objectTurboSponge256 implements sponge expansion for the TurboShake256 XOF
- read(n)
Read n bytes of data from the TurboShake256 XOF
Example:
>>> from xoflib import TurboShake256 >>> xof = TurboShake256(1, b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> xof.read(16).hex() '2e9d18d326438ea968b071ab958f6260'
- read_into(buf)
Fill the input buffer with data from the TurboShake256 XOF Example:
>>> from xoflib import TurboShake256 >>> xof = TurboShake256(1, b"bytes to absorb") >>> xof = xof.absorb(bytearray(b"Ooh just a little bit more data")).finalize() >>> buf = bytearray(b"\0" * 10) >>> xof.read_into(buf) >>> buf.hex() '2e9d18d326438ea968b071ab958f6260'
- xoflib.ascon_xof(data)
Construct a AsconSponge directly from data
Example:
>>> from xoflib import ascon_xof >>> xof = ascon_xof(b"bytes to absorb") >>> xof.read(16).hex() 'd7bbe757e53015382e3ee13a2207fafc'
- xoflib.ascona_xof(data)
Construct a AsconASponge directly from data
Example:
>>> from xoflib import ascona_xof >>> xof = ascona_xof(b"bytes to absorb") >>> xof.read(16).hex() 'ae7ba96550a57300da1e2ba31335d922'
- xoflib.blake3_xof(data)
Construct a Blake3Sponge directly from data
Example:
>>> from xoflib import blake3_xof >>> xof = blake3_xof(b"bytes to absorb") >>> xof.read(16).hex() 'not yet'
- xoflib.shake128(data)
Construct a Sponge128 directly from data
Example:
>>> from xoflib import shake128 >>> xof = shake128(b"bytes to absorb") >>> xof.read(16).hex() '250ef380a0f0c92e9506af9893f640fa'
- xoflib.shake256(data)
Construct a Sponge256 directly from data
Example:
>>> from xoflib import shake256 >>> xof = shake256(b"bytes to absorb") >>> xof.read(16).hex() '1e54f9f0cbacb3573a05dd5d48ea4104'
- xoflib.turbo_shake128(domain_sep, data)
Construct a TurboSponge128 directly from domain_sep and data
Example:
>>> from xoflib import turbo_shake128 >>> xof = turbo_shake128(1, b"bytes to absorb") >>> xof.read(16).hex() '4bb4e35b21335fcc6ae6cd3d0a5fe005'
- xoflib.turbo_shake256(domain_sep, data)
Construct a TurboSponge256 directly from domain_sep and data
Example:
>>> from xoflib import turbo_shake256 >>> xof = turbo_shake256(1, b"bytes to absorb") >>> xof.read(16).hex() 'd671d0021e9f22293d062259e68e6e89'