fix ethers import

This commit is contained in:
Danil Kovtonyuk 2022-03-17 19:55:47 +10:00
parent 3f84f4fbf7
commit fdaafd32eb
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746
12 changed files with 25 additions and 28 deletions

View File

@ -12,7 +12,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var blake2b__default = /*#__PURE__*/_interopDefaultLegacy(blake2b);
var createBlakeHash__default = /*#__PURE__*/_interopDefaultLegacy(createBlakeHash);
var ethers__default = /*#__PURE__*/_interopDefaultLegacy(ethers);
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
async function buildBabyJub() {
@ -294,7 +293,7 @@ class Mimc7 {
getIV(seed) {
const F = this.F;
if (typeof seed === "undefined") seed = SEED$1;
const c = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(seed+"_iv"));
const c = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(seed+"_iv"));
const cn = ffjavascript.Scalar.e(c);
const iv = ffjavascript.Scalar.mod(cn, F.p);
return iv;
@ -304,9 +303,9 @@ class Mimc7 {
const F = this.F;
if (typeof nRounds === "undefined") nRounds = NROUNDS$1;
const cts = new Array(nRounds);
let c = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(SEED$1));
let c = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(SEED$1));
for (let i=1; i<nRounds; i++) {
c = ethers__default["default"].utils.keccak256(c);
c = ethers.ethers.utils.keccak256(c);
cts[i] = F.e(c);
}
@ -25268,7 +25267,7 @@ class MimcSponge {
getIV (seed) {
const F = this.F;
if (typeof seed === "undefined") seed = SEED;
const c = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(seed+"_iv"));
const c = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(seed+"_iv"));
const cn = ffjavascript.Scalar.e(c);
const iv = cn.mod(F.p);
return iv;
@ -25278,8 +25277,8 @@ class MimcSponge {
const F = this.F;
if (typeof nRounds === "undefined") nRounds = NROUNDS;
const cts = new Array(nRounds);
let c = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(SEED)); for (let i=1; i<nRounds; i++) {
c = ethers__default["default"].utils.keccak256(c);
let c = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(SEED)); for (let i=1; i<nRounds; i++) {
c = ethers.ethers.utils.keccak256(c);
cts[i] = F.e(c);
}
@ -25658,7 +25657,7 @@ class Contract {
genLoadedLength = C.code.length;
}
return ethers__default["default"].utils.hexlify(C.code.concat(this.code));
return ethers.ethers.utils.hexlify(C.code.concat(this.code));
}
stop() { this.code.push(0x00); }
@ -25784,7 +25783,7 @@ class Contract {
S = "0x" +S;
data = S;
}
const d = ethers__default["default"].utils.arrayify(data);
const d = ethers.ethers.utils.arrayify(data);
if (d.length == 0 || d.length > 32) {
throw new Error("Assertion failed");
}
@ -25830,7 +25829,7 @@ class Contract {
function createCode$2(seed, n) {
let ci = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(seed));
let ci = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(seed));
const C = new Contract();
C.push(0x44);
@ -25872,7 +25871,7 @@ function createCode$2(seed, n) {
C.mulmod(); // r=t^7 k q
for (let i=0; i<n-1; i++) {
ci = ethers__default["default"].utils.keccak256(ci);
ci = ethers.ethers.utils.keccak256(ci);
C.dup(2); // q r k q
C.dup(0); // q q r k q
C.dup(0); // q q q r k q
@ -25940,7 +25939,7 @@ var _mimc7Contract = /*#__PURE__*/Object.freeze({
function createCode$1(seed, n) {
let ci = ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(seed));
let ci = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(seed));
const C = new Contract();
@ -25983,7 +25982,7 @@ function createCode$1(seed, n) {
for (let i=0; i<n-1; i++) {
if (i < n-2) {
ci = ethers__default["default"].utils.keccak256(ci);
ci = ethers.ethers.utils.keccak256(ci);
} else {
ci = "0x00";
}
@ -26366,10 +26365,10 @@ function createCode(nInputs) {
C.calldataload();
C.div();
C.dup(0);
C.push(ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(`poseidon(uint256[${nInputs}])`)).slice(0, 10)); // poseidon(uint256[n])
C.push(ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(`poseidon(uint256[${nInputs}])`)).slice(0, 10)); // poseidon(uint256[n])
C.eq();
C.swap(1);
C.push(ethers__default["default"].utils.keccak256(ethers__default["default"].utils.toUtf8Bytes(`poseidon(bytes32[${nInputs}])`)).slice(0, 10)); // poseidon(bytes32[n])
C.push(ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(`poseidon(bytes32[${nInputs}])`)).slice(0, 10)); // poseidon(bytes32[n])
C.eq();
C.or();
C.jmpi("start");

View File

@ -10,7 +10,7 @@ export {default as buildMimcSponge} from "./src/mimcsponge.js";
import * as _mimcSpongeContract from "./src/mimcsponge_gencontract.js";
export const mimcSpongecontract=_mimcSpongeContract;
export {default as buildPedersenHash} from "./src/pedersenhash.js";
export { default as buildPedersenHash } from "./src/pedersenHash.js";
export {default as buildPoseidon} from "./src/poseidon.js";
import * as _poseidonContract from "./src/poseidon_gencontract.js";

View File

@ -1,6 +1,6 @@
import { Scalar } from "ffjavascript";
import buildBabyJub from "./babyjub.js";
import buildPedersenHash from "./pedersenhash.js";
import buildPedersenHash from "./pedersenHash.js";
import buildMimc7 from "./mimc7.js";
import buildPoseidon from "./poseidon.js";
import buildMimcSponge from "./mimcsponge.js";

View File

@ -2,8 +2,7 @@
// License: LGPL-3.0+
//
import ethers from "ethers";
import { ethers } from "ethers";
import {Scalar} from "ffjavascript";
export default class Contract {

View File

@ -1,7 +1,6 @@
import {getCurveFromName, Scalar} from "ffjavascript";
import ethers from "ethers";
import { ethers } from "ethers";
const SEED = "mimc";
const NROUNDS = 91;

View File

@ -2,7 +2,7 @@
// License: LGPL-3.0+
//
import ethers from "ethers";
import { ethers } from "ethers";
import Contract from "./evmasm.js";

View File

@ -1,5 +1,5 @@
import { Scalar, getCurveFromName } from "ffjavascript";
import ethers from "ethers";
import { ethers } from "ethers";
const SEED = "mimcsponge";
const NROUNDS = 220;

View File

@ -2,7 +2,7 @@
// License: LGPL-3.0+
//
import ethers from "ethers";
import { ethers } from "ethers";
import Contract from "./evmasm.js";

View File

@ -5,7 +5,7 @@
import Contract from "./evmasm.js";
import { utils } from "ffjavascript";
const { unstringifyBigInts } = utils;
import ethers from "ethers";
import { ethers } from "ethers";
import poseidonConstants from "./poseidon_constants.js";

View File

@ -1,6 +1,6 @@
import chai from "chai";
import {createCode, abi} from "../src/mimc7_gencontract.js";
import ethers from "ethers";
import { ethers } from "ethers";
import ganache from "ganache-cli";
import buildMimc7 from "../src/mimc7.js";

View File

@ -1,6 +1,6 @@
import chai from "chai";
import {createCode, abi} from "../src/mimcsponge_gencontract.js";
import ethers from "ethers";
import { ethers } from "ethers";
import ganache from "ganache-cli";
import buildMimcSponge from "../src/mimcsponge.js";

View File

@ -1,7 +1,7 @@
import chai from "chai";
import {createCode, generateABI} from "../src/poseidon_gencontract.js";
import buildPoseidon from "../src/poseidon.js";
import ethers from "ethers";
import { ethers } from "ethers";
import ganache from "ganache-cli";
const assert = chai.assert;