Skip to main content

Module sui::bls12381

Group operations of BLS12-381.

use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::bcs;
use sui::group_ops;
use sui::hex;

Struct Scalar

public struct Scalar
Fields

Struct G1

public struct G1
Fields

Struct G2

public struct G2
Fields

Struct GT

public struct GT
Fields

Struct UncompressedG1

public struct UncompressedG1
Fields

Constants

const SCALAR_ZERO_BYTES: vector<u8> = vector[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const SCALAR_ONE_BYTES: vector<u8> = vector[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
const G1_IDENTITY_BYTES: vector<u8> = vector[192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const G1_GENERATOR_BYTES: vector<u8> = vector[151, 241, 211, 167, 49, 151, 215, 148, 38, 149, 99, 140, 79, 169, 172, 15, 195, 104, 140, 79, 151, 116, 185, 5, 161, 78, 58, 63, 23, 27, 172, 88, 108, 85, 232, 63, 249, 122, 26, 239, 251, 58, 240, 10, 219, 34, 198, 187];
const G2_IDENTITY_BYTES: vector<u8> = vector[192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const G2_GENERATOR_BYTES: vector<u8> = vector[147, 224, 43, 96, 82, 113, 159, 96, 125, 172, 211, 160, 136, 39, 79, 101, 89, 107, 208, 208, 153, 32, 182, 26, 181, 218, 97, 187, 220, 127, 80, 73, 51, 76, 241, 18, 19, 148, 93, 87, 229, 172, 125, 5, 93, 4, 43, 126, 2, 74, 162, 178, 240, 143, 10, 145, 38, 8, 5, 39, 45, 197, 16, 81, 198, 228, 122, 212, 250, 64, 59, 2, 180, 81, 11, 100, 122, 227, 209, 119, 11, 172, 3, 38, 168, 5, 187, 239, 212, 128, 86, 200, 193, 33, 189, 184];
const GT_IDENTITY_BYTES: vector<u8> = vector[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const GT_GENERATOR_BYTES: vector<u8> = vector[18, 80, 235, 216, 113, 252, 10, 146, 167, 178, 216, 49, 104, 208, 215, 39, 39, 45, 68, 27, 239, 161, 92, 80, 61, 216, 233, 12, 233, 141, 179, 231, 182, 209, 148, 246, 8, 57, 197, 8, 168, 67, 5, 170, 202, 23, 137, 182, 8, 154, 28, 91, 70, 229, 17, 11, 134, 117, 14, 198, 165, 50, 52, 136, 104, 168, 64, 69, 72, 60, 146, 183, 175, 90, 246, 137, 69, 46, 175, 171, 241, 168, 148, 62, 80, 67, 159, 29, 89, 136, 42, 152, 234, 160, 23, 15, 25, 242, 99, 55, 210, 5, 251, 70, 156, 214, 189, 21, 195, 213, 160, 77, 200, 135, 132, 251, 179, 208, 178, 219, 222, 165, 77, 67, 178, 183, 63, 44, 187, 18, 213, 131, 134, 168, 112, 62, 15, 148, 130, 38, 228, 126, 232, 157, 6, 251, 162, 62, 183, 197, 175, 13, 159, 128, 148, 12, 167, 113, 182, 255, 213, 133, 123, 170, 242, 34, 235, 149, 167, 210, 128, 157, 97, 191, 224, 46, 27, 253, 27, 104, 255, 2, 240, 184, 16, 42, 225, 194, 213, 213, 171, 26, 19, 104, 187, 68, 92, 124, 45, 32, 151, 3, 242, 57, 104, 156, 227, 76, 3, 120, 166, 142, 114, 166, 179, 178, 22, 218, 14, 34, 165, 3, 27, 84, 221, 255, 87, 48, 147, 150, 179, 140, 136, 28, 76, 132, 158, 194, 62, 135, 25, 53, 2, 184, 110, 219, 136, 87, 194, 115, 250, 7, 90, 80, 81, 41, 55, 224, 121, 78, 30, 101, 167, 97, 124, 144, 216, 189, 102, 6, 91, 31, 255, 229, 29, 122, 87, 153, 115, 177, 49, 80, 33, 236, 60, 25, 147, 79, 17, 184, 180, 36, 205, 72, 191, 56, 252, 239, 104, 8, 59, 11, 14, 197, 200, 26, 147, 179, 48, 238, 26, 103, 125, 13, 21, 255, 123, 152, 78, 137, 120, 239, 72, 136, 30, 50, 250, 201, 27, 147, 180, 115, 51, 226, 186, 87, 3, 53, 15, 85, 167, 174, 252, 211, 195, 27, 79, 203, 108, 229, 119, 28, 198, 160, 233, 120, 106, 181, 151, 51, 32, 200, 6, 173, 54, 8, 41, 16, 123, 168, 16, 197, 160, 159, 253, 217, 190, 34, 145, 160, 194, 90, 153, 162, 1, 178, 245, 34, 71, 61, 23, 19, 145, 18, 91, 168, 77, 196, 0, 124, 251, 242, 248, 218, 117, 47, 124, 116, 24, 82, 3, 252, 202, 88, 154, 199, 25, 195, 77, 255, 187, 170, 216, 67, 29, 173, 28, 31, 181, 151, 170, 165, 1, 129, 7, 21, 79, 37, 167, 100, 189, 60, 121, 147, 122, 69, 184, 69, 70, 218, 99, 75, 143, 107, 225, 74, 128, 97, 229, 92, 206, 186, 71, 139, 35, 247, 218, 202, 163, 92, 140, 167, 139, 234, 233, 98, 64, 69, 180, 182, 4, 197, 129, 35, 77, 8, 106, 153, 2, 36, 155, 100, 114, 143, 253, 33, 161, 137, 232, 121, 53, 169, 84, 5, 28, 124, 219, 167, 179, 135, 38, 41, 164, 250, 252, 5, 6, 98, 69, 203, 145, 8, 240, 36, 45, 15, 227, 239, 15, 65, 229, 134, 99, 191, 8, 207, 6, 134, 114, 203, 208, 26, 126, 199, 59, 172, 164, 215, 44, 169, 53, 68, 222, 255, 104, 107, 253, 109, 245, 67, 212, 142, 170, 36, 175, 228, 126, 30, 253, 228, 73, 56, 59, 103, 102, 49];
const SCALAR_TYPE: u8 = 0;
const G1_TYPE: u8 = 1;
const G2_TYPE: u8 = 2;
const GT_TYPE: u8 = 3;
const UNCOMPRESSED_G1_TYPE: u8 = 4;

Function bls12381_min_sig_verify

@param signature: A 48-bytes signature that is a point on the G1 subgroup. @param public_key: A 96-bytes public key that is a point on the G2 subgroup. @param msg: The message that we test the signature against.

If the signature is a valid signature of the message and public key according to BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_, return true. Otherwise, return false.

public fun bls12381_min_sig_verify(signature: &vector<u8>, public_key: &vector<u8>, msg: &vector<u8>): bool
Implementation
public native fun bls12381_min_sig_verify(
    signature: &vector<u8>,
    public_key: &vector<u8>,
    msg: &vector<u8>,
): bool;

Function bls12381_min_pk_verify

@param signature: A 96-bytes signature that is a point on the G2 subgroup. @param public_key: A 48-bytes public key that is a point on the G1 subgroup. @param msg: The message that we test the signature against.

If the signature is a valid signature of the message and public key according to BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_, return true. Otherwise, return false.

public fun bls12381_min_pk_verify(signature: &vector<u8>, public_key: &vector<u8>, msg: &vector<u8>): bool
Implementation
public native fun bls12381_min_pk_verify(
    signature: &vector<u8>,
    public_key: &vector<u8>,
    msg: &vector<u8>,
): bool;

Function scalar_from_bytes

public fun scalar_from_bytes(bytes: &vector<u8>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_from_bytes(bytes: &vector<u8>): Element<Scalar> {
    group_ops::from_bytes(SCALAR_TYPE, bytes, false)
}

Function scalar_from_u64

public fun scalar_from_u64(x: u64): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_from_u64(x: u64): Element<Scalar> {
    let mut bytes = SCALAR_ZERO_BYTES;
    group_ops::set_as_prefix(x, true, &mut bytes);
    group_ops::from_bytes(SCALAR_TYPE, &bytes, true)
}

Function scalar_zero

public fun scalar_zero(): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_zero(): Element<Scalar> {
    let zero = SCALAR_ZERO_BYTES;
    group_ops::from_bytes(SCALAR_TYPE, &zero, true)
}

Function scalar_one

public fun scalar_one(): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_one(): Element<Scalar> {
    let one = SCALAR_ONE_BYTES;
    group_ops::from_bytes(SCALAR_TYPE, &one, true)
}

Function scalar_add

public fun scalar_add(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_add(e1: &Element<Scalar>, e2: &Element<Scalar>): Element<Scalar> {
    group_ops::add(SCALAR_TYPE, e1, e2)
}

Function scalar_sub

public fun scalar_sub(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_sub(e1: &Element<Scalar>, e2: &Element<Scalar>): Element<Scalar> {
    group_ops::sub(SCALAR_TYPE, e1, e2)
}

Function scalar_mul

public fun scalar_mul(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_mul(e1: &Element<Scalar>, e2: &Element<Scalar>): Element<Scalar> {
    group_ops::mul(SCALAR_TYPE, e1, e2)
}

Function scalar_div

Returns e2/e1, fails if a is zero.

public fun scalar_div(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_div(e1: &Element<Scalar>, e2: &Element<Scalar>): Element<Scalar> {
    group_ops::div(SCALAR_TYPE, e1, e2)
}

Function scalar_neg

public fun scalar_neg(e: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_neg(e: &Element<Scalar>): Element<Scalar> {
    scalar_sub(&scalar_zero(), e)
}

Function scalar_inv

public fun scalar_inv(e: &sui::group_ops::Element<sui::bls12381::Scalar>): sui::group_ops::Element<sui::bls12381::Scalar>
Implementation
public fun scalar_inv(e: &Element<Scalar>): Element<Scalar> {
    scalar_div(e, &scalar_one())
}

Function g1_from_bytes

public fun g1_from_bytes(bytes: &vector<u8>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_from_bytes(bytes: &vector<u8>): Element<G1> {
    group_ops::from_bytes(G1_TYPE, bytes, false)
}

Function g1_identity

public fun g1_identity(): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_identity(): Element<G1> {
    let identity = G1_IDENTITY_BYTES;
    group_ops::from_bytes(G1_TYPE, &identity, true)
}

Function g1_generator

public fun g1_generator(): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_generator(): Element<G1> {
    let generator = G1_GENERATOR_BYTES;
    group_ops::from_bytes(G1_TYPE, &generator, true)
}

Function g1_add

public fun g1_add(e1: &sui::group_ops::Element<sui::bls12381::G1>, e2: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_add(e1: &Element<G1>, e2: &Element<G1>): Element<G1> {
    group_ops::add(G1_TYPE, e1, e2)
}

Function g1_sub

public fun g1_sub(e1: &sui::group_ops::Element<sui::bls12381::G1>, e2: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_sub(e1: &Element<G1>, e2: &Element<G1>): Element<G1> {
    group_ops::sub(G1_TYPE, e1, e2)
}

Function g1_mul

public fun g1_mul(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_mul(e1: &Element<Scalar>, e2: &Element<G1>): Element<G1> {
    group_ops::mul(G1_TYPE, e1, e2)
}

Function g1_div

Returns e2 / e1, fails if scalar is zero.

public fun g1_div(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_div(e1: &Element<Scalar>, e2: &Element<G1>): Element<G1> {
    group_ops::div(G1_TYPE, e1, e2)
}

Function g1_neg

public fun g1_neg(e: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_neg(e: &Element<G1>): Element<G1> {
    g1_sub(&g1_identity(), e)
}

Function hash_to_g1

Hash using DST = BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_

public fun hash_to_g1(m: &vector<u8>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun hash_to_g1(m: &vector<u8>): Element<G1> {
    group_ops::hash_to(G1_TYPE, m)
}

Function g1_multi_scalar_multiplication

Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, e2, ..., en]. Returns s1e1 + s2e2 + ... + sn*en. Aborts with EInputTooLong if the vectors are larger than 32 (may increase in the future).

public fun g1_multi_scalar_multiplication(scalars: &vector<sui::group_ops::Element<sui::bls12381::Scalar>>, elements: &vector<sui::group_ops::Element<sui::bls12381::G1>>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun g1_multi_scalar_multiplication(
    scalars: &vector<Element<Scalar>>,
    elements: &vector<Element<G1>>,
): Element<G1> {
    group_ops::multi_scalar_multiplication(G1_TYPE, scalars, elements)
}

Function g1_to_uncompressed_g1

Convert an Element<G1> to uncompressed form.

public fun g1_to_uncompressed_g1(e: &sui::group_ops::Element<sui::bls12381::G1>): sui::group_ops::Element<sui::bls12381::UncompressedG1>
Implementation
public fun g1_to_uncompressed_g1(e: &Element<G1>): Element<UncompressedG1> {
    group_ops::convert(G1_TYPE, UNCOMPRESSED_G1_TYPE, e)
}

Function g2_from_bytes

public fun g2_from_bytes(bytes: &vector<u8>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_from_bytes(bytes: &vector<u8>): Element<G2> {
    group_ops::from_bytes(G2_TYPE, bytes, false)
}

Function g2_identity

public fun g2_identity(): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_identity(): Element<G2> {
    let identity = G2_IDENTITY_BYTES;
    group_ops::from_bytes(G2_TYPE, &identity, true)
}

Function g2_generator

public fun g2_generator(): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_generator(): Element<G2> {
    let generator = G2_GENERATOR_BYTES;
    group_ops::from_bytes(G2_TYPE, &generator, true)
}

Function g2_add

public fun g2_add(e1: &sui::group_ops::Element<sui::bls12381::G2>, e2: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_add(e1: &Element<G2>, e2: &Element<G2>): Element<G2> {
    group_ops::add(G2_TYPE, e1, e2)
}

Function g2_sub

public fun g2_sub(e1: &sui::group_ops::Element<sui::bls12381::G2>, e2: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_sub(e1: &Element<G2>, e2: &Element<G2>): Element<G2> {
    group_ops::sub(G2_TYPE, e1, e2)
}

Function g2_mul

public fun g2_mul(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_mul(e1: &Element<Scalar>, e2: &Element<G2>): Element<G2> {
    group_ops::mul(G2_TYPE, e1, e2)
}

Function g2_div

Returns e2 / e1, fails if scalar is zero.

public fun g2_div(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_div(e1: &Element<Scalar>, e2: &Element<G2>): Element<G2> {
    group_ops::div(G2_TYPE, e1, e2)
}

Function g2_neg

public fun g2_neg(e: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_neg(e: &Element<G2>): Element<G2> {
    g2_sub(&g2_identity(), e)
}

Function hash_to_g2

Hash using DST = BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_

public fun hash_to_g2(m: &vector<u8>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun hash_to_g2(m: &vector<u8>): Element<G2> {
    group_ops::hash_to(G2_TYPE, m)
}

Function g2_multi_scalar_multiplication

Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, e2, ..., en]. Returns s1e1 + s2e2 + ... + sn*en. Aborts with EInputTooLong if the vectors are larger than 32 (may increase in the future).

public fun g2_multi_scalar_multiplication(scalars: &vector<sui::group_ops::Element<sui::bls12381::Scalar>>, elements: &vector<sui::group_ops::Element<sui::bls12381::G2>>): sui::group_ops::Element<sui::bls12381::G2>
Implementation
public fun g2_multi_scalar_multiplication(
    scalars: &vector<Element<Scalar>>,
    elements: &vector<Element<G2>>,
): Element<G2> {
    group_ops::multi_scalar_multiplication(G2_TYPE, scalars, elements)
}

Function gt_identity

public fun gt_identity(): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_identity(): Element<GT> {
    let identity = GT_IDENTITY_BYTES;
    group_ops::from_bytes(GT_TYPE, &identity, true)
}

Function gt_generator

public fun gt_generator(): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_generator(): Element<GT> {
    let generator = GT_GENERATOR_BYTES;
    group_ops::from_bytes(GT_TYPE, &generator, true)
}

Function gt_add

public fun gt_add(e1: &sui::group_ops::Element<sui::bls12381::GT>, e2: &sui::group_ops::Element<sui::bls12381::GT>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_add(e1: &Element<GT>, e2: &Element<GT>): Element<GT> {
    group_ops::add(GT_TYPE, e1, e2)
}

Function gt_sub

public fun gt_sub(e1: &sui::group_ops::Element<sui::bls12381::GT>, e2: &sui::group_ops::Element<sui::bls12381::GT>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_sub(e1: &Element<GT>, e2: &Element<GT>): Element<GT> {
    group_ops::sub(GT_TYPE, e1, e2)
}

Function gt_mul

public fun gt_mul(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::GT>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_mul(e1: &Element<Scalar>, e2: &Element<GT>): Element<GT> {
    group_ops::mul(GT_TYPE, e1, e2)
}

Function gt_div

Returns e2 / e1, fails if scalar is zero.

public fun gt_div(e1: &sui::group_ops::Element<sui::bls12381::Scalar>, e2: &sui::group_ops::Element<sui::bls12381::GT>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_div(e1: &Element<Scalar>, e2: &Element<GT>): Element<GT> {
    group_ops::div(GT_TYPE, e1, e2)
}

Function gt_neg

public fun gt_neg(e: &sui::group_ops::Element<sui::bls12381::GT>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun gt_neg(e: &Element<GT>): Element<GT> {
    gt_sub(&gt_identity(), e)
}

Function pairing

public fun pairing(e1: &sui::group_ops::Element<sui::bls12381::G1>, e2: &sui::group_ops::Element<sui::bls12381::G2>): sui::group_ops::Element<sui::bls12381::GT>
Implementation
public fun pairing(e1: &Element<G1>, e2: &Element<G2>): Element<GT> {
    group_ops::pairing(G1_TYPE, e1, e2)
}

Function uncompressed_g1_to_g1

UncompressedG1 group operations /// Create a Element<G1> from its uncompressed form.

public fun uncompressed_g1_to_g1(e: &sui::group_ops::Element<sui::bls12381::UncompressedG1>): sui::group_ops::Element<sui::bls12381::G1>
Implementation
public fun uncompressed_g1_to_g1(e: &Element<UncompressedG1>): Element<G1> {
    group_ops::convert(UNCOMPRESSED_G1_TYPE, G1_TYPE, e)
}

Function uncompressed_g1_sum

Compute the sum of a list of uncompressed elements. This is significantly faster and cheaper than summing the elements.

public fun uncompressed_g1_sum(terms: &vector<sui::group_ops::Element<sui::bls12381::UncompressedG1>>): sui::group_ops::Element<sui::bls12381::UncompressedG1>
Implementation
public fun uncompressed_g1_sum(terms: &vector<Element<UncompressedG1>>): Element<UncompressedG1> {
    group_ops::sum(UNCOMPRESSED_G1_TYPE, terms)
}