G1Element.fromBytes constructor

G1Element.fromBytes({
  1. required Uint8List data,
})

Create a G1Element instance from data.

Implementation

factory G1Element.fromBytes({required Uint8List data}) {
  final dataBuf = malloc.allocate<Uint8>(data.length)
    ..asTypedList(data.length).setAll(0, data);

  final didErr = calloc.allocate<Bool>(1);
  final g1 = G1Element(
    bindings.CG1ElementFromBytes(dataBuf.cast(), didErr.cast()),
  );
  malloc.free(dataBuf);
  if (didErr.value) {
    malloc.free(didErr);
    throw BLSException.errFromC();
  }
  malloc.free(didErr);
  return g1;
}