Beispiel #1
0
def serialize(g: Big384, largerY: bool) -> bytearray:
    buffer: Array[c_char] = create_string_buffer(48)
    MilagroCurve.BIG_384_58_toBytes(buffer, g)

    result: bytearray = bytearray(buffer)
    result[0] = result[0] | C_FLAG

    inf: int = 1
    if result[0] == C_FLAG:
        while inf < 48:
            if result[inf] != 0:
                break
            inf += 1
        if inf == 48:
            result[0] = result[0] | B_FLAG
            return result

    if largerY:
        result[0] = result[0] | A_FLAG

    return result
Beispiel #2
0
 def serialize(self) -> bytes:
     result: Array[c_char] = create_string_buffer(48)
     MilagroCurve.BIG_384_58_toBytes(result, self.value)
     return bytes(result)
Beispiel #3
0
 def sign(self) -> int:
     buffer: Array[c_char] = create_string_buffer(48)
     MilagroCurve.BIG_384_58_toBytes(buffer, self.value.toBig384())
     return bytes(buffer)[-1] & 0b1
Beispiel #4
0
 def serialize(self) -> str:
     buffer: Array[c_char] = create_string_buffer(48)
     MilagroCurve.BIG_384_58_toBytes(buffer, self.value.toBig384())
     return bytes(buffer).hex()