Utils

CryptoGroups.Utils.@hex_strMacro
@hex_str(x)::Vector{UInt8}

A convinience macro for converting a hex to byte vector:

hex"AAEF BBEC" == UInt8[0xaa, 0xef, 0xbb, 0xec]
source
CryptoGroups.Utils.int2octetMethod
int2octet(x::Integer, N::Int = bitlength(x))::Vector{UInt8}

Converts integer x into an octet where optional N specifies number of allocated bits for the integer encoding.

source
CryptoGroups.Utils.octet2intMethod
octet2int(x::Vector{UInt8})::BigInt
octet2int(x::String)::BigInt

Converts a binary octet to a BigInt. In case a string is passed it is treated as hexadecimal and is converted with hex2bytes. Equivalent in represeentation as parse(BigInt, bytes2hex(x), base=16).

source
CryptoGroups.Utils.staticMethod
static(x)
static(; kwargs...)

If x is not bitstype converts to a bitstype representation. Keyword arguments are used to construct a named tuple with every value being converted with static. Can be converted back to original type with dynamic method.

Example

# Single argument case
x = BigInt(23)
isbitstype(typeof(x)) == false
isbitstype(typeof(static(x))) == true
x == dynamic(static(x))

# NamedTuple construction

nt = static(; x = BigInt(23), y = 51, z = :name)
isbittstype(typeof(nt)) == true
nt.x == BigInt(23) # accessor methods do conversion with dynamic
dynamic(nt) # ordinary named tuple with every value made dynamic
source