MCPcopy Create free account
hub / github.com/cryptidtech/oberon / _encode_bytes

Function _encode_bytes

python/oberon/bindings.py:53–73  ·  view source on GitHub ↗
(arg: Optional[Union[str, bytes, FfiByteBuffer]])

Source from the content-addressed store, hash-verified

51
52
53def _encode_bytes(arg: Optional[Union[str, bytes, FfiByteBuffer]]) -> FfiByteBuffer:
54 if isinstance(arg, FfiByteBuffer):
55 return arg
56 buf = FfiByteBuffer()
57 if isinstance(arg, memoryview):
58 buf.length = arg.nbytes
59 if arg.contiguous and not arg.readonly:
60 buf.data = (c_ubyte * buf.length).from_buffer(arg.obj)
61 else:
62 buf.data = (c_ubyte * buf.length).from_buffer_copy(arg.obj)
63 elif isinstance(arg, bytearray):
64 buf.length = len(arg)
65 if buf.length > 0:
66 buf.data = (c_ubyte * buf.length).from_buffer(arg)
67 elif arg is not None:
68 if isinstance(arg, str):
69 arg = arg.encode("utf-8")
70 buf.length = len(arg)
71 if buf.length > 0:
72 buf.data = (c_ubyte * buf.length).from_buffer_copy(arg)
73 return buf
74
75
76def _load_library(lib_name: str) -> CDLL:

Callers 8

get_public_keyFunction · 0.85
secret_key_from_seedFunction · 0.85
new_tokenFunction · 0.85
verify_tokenFunction · 0.85
add_blindingFunction · 0.85
remove_blindingFunction · 0.85
create_proofFunction · 0.85
verify_proofFunction · 0.85

Calls 1

FfiByteBufferClass · 0.85

Tested by

no test coverage detected