Comparing version 0.0.69 to 0.0.70
@@ -638,2 +638,26 @@ import { check } from "./system"; | ||
export class AltBn128Pair implements Packer { | ||
constructor( | ||
public g1: AltBn128G1 = new AltBn128G1(), | ||
public g2: AltBn128G2 = new AltBn128G2(), | ||
) {} | ||
pack(): u8[] { | ||
const rawG1 = this.g1.pack(); | ||
const rawG2 = this.g2.pack(); | ||
return rawG1.concat(rawG2); | ||
} | ||
unpack(data: u8[]): usize { | ||
let dec = new Decoder(data); | ||
this.g1.unpack(dec.unpackBytes(64)) | ||
this.g2.unpack(dec.unpackBytes(128)) | ||
return dec.getPos(); | ||
} | ||
getSize(): usize { | ||
return 192; | ||
} | ||
} | ||
export function bn128Add(op1: AltBn128G1, op2: AltBn128G1): AltBn128G1 { | ||
@@ -661,6 +685,6 @@ const rawOp1 = op1.pack(); | ||
export function bn128Pair(pairs: [AltBn128G1, AltBn128G2][]): boolean { | ||
export function bn128Pair(pairs: AltBn128Pair[]): boolean { | ||
let input: u8[] = [] | ||
for (let i=0; i<pairs.length; i++) { | ||
input = input.concat(pairs[i][0].pack()).concat(pairs[i][1].pack()) | ||
input = input.concat(pairs[i].pack()) | ||
} | ||
@@ -667,0 +691,0 @@ const ret = env.alt_bn128_pair(input.dataStart, input.length) |
@@ -131,2 +131,3 @@ export { U128, U256, I128 } from "./bignum"; | ||
AltBn128G2, | ||
AltBn128Pair, | ||
bn128Add, | ||
@@ -133,0 +134,0 @@ bn128Mul, |
{ | ||
"name": "as-chain", | ||
"version": "0.0.69", | ||
"version": "0.0.70", | ||
"description": "chain module for assemblyscript", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1574104
6663