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 blake2b__default = /*#__PURE__*/_interopDefaultLegacy(blake2b);
var createBlakeHash__default = /*#__PURE__*/_interopDefaultLegacy(createBlakeHash); var createBlakeHash__default = /*#__PURE__*/_interopDefaultLegacy(createBlakeHash);
var ethers__default = /*#__PURE__*/_interopDefaultLegacy(ethers);
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
async function buildBabyJub() { async function buildBabyJub() {
@ -294,7 +293,7 @@ class Mimc7 {
getIV(seed) { getIV(seed) {
const F = this.F; const F = this.F;
if (typeof seed === "undefined") seed = SEED$1; 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 cn = ffjavascript.Scalar.e(c);
const iv = ffjavascript.Scalar.mod(cn, F.p); const iv = ffjavascript.Scalar.mod(cn, F.p);
return iv; return iv;
@ -304,9 +303,9 @@ class Mimc7 {
const F = this.F; const F = this.F;
if (typeof nRounds === "undefined") nRounds = NROUNDS$1; if (typeof nRounds === "undefined") nRounds = NROUNDS$1;
const cts = new Array(nRounds); 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++) { 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); cts[i] = F.e(c);
} }
@ -25268,7 +25267,7 @@ class MimcSponge {
getIV (seed) { getIV (seed) {
const F = this.F; const F = this.F;
if (typeof seed === "undefined") seed = SEED; 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 cn = ffjavascript.Scalar.e(c);
const iv = cn.mod(F.p); const iv = cn.mod(F.p);
return iv; return iv;
@ -25278,8 +25277,8 @@ class MimcSponge {
const F = this.F; const F = this.F;
if (typeof nRounds === "undefined") nRounds = NROUNDS; if (typeof nRounds === "undefined") nRounds = NROUNDS;
const cts = new Array(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++) { let c = ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(SEED)); 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); cts[i] = F.e(c);
} }
@ -25658,7 +25657,7 @@ class Contract {
genLoadedLength = C.code.length; 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); } stop() { this.code.push(0x00); }
@ -25784,7 +25783,7 @@ class Contract {
S = "0x" +S; S = "0x" +S;
data = 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) { if (d.length == 0 || d.length > 32) {
throw new Error("Assertion failed"); throw new Error("Assertion failed");
} }
@ -25830,7 +25829,7 @@ class Contract {
function createCode$2(seed, n) { 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(); const C = new Contract();
C.push(0x44); C.push(0x44);
@ -25872,7 +25871,7 @@ function createCode$2(seed, n) {
C.mulmod(); // r=t^7 k q C.mulmod(); // r=t^7 k q
for (let i=0; i<n-1; i++) { 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(2); // q r k q
C.dup(0); // q q r k q C.dup(0); // q q r k q
C.dup(0); // q 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) { 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(); const C = new Contract();
@ -25983,7 +25982,7 @@ function createCode$1(seed, n) {
for (let i=0; i<n-1; i++) { for (let i=0; i<n-1; i++) {
if (i < n-2) { if (i < n-2) {
ci = ethers__default["default"].utils.keccak256(ci); ci = ethers.ethers.utils.keccak256(ci);
} else { } else {
ci = "0x00"; ci = "0x00";
} }
@ -26366,10 +26365,10 @@ function createCode(nInputs) {
C.calldataload(); C.calldataload();
C.div(); C.div();
C.dup(0); 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.eq();
C.swap(1); 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.eq();
C.or(); C.or();
C.jmpi("start"); 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"; import * as _mimcSpongeContract from "./src/mimcsponge_gencontract.js";
export const mimcSpongecontract=_mimcSpongeContract; 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"; export {default as buildPoseidon} from "./src/poseidon.js";
import * as _poseidonContract from "./src/poseidon_gencontract.js"; import * as _poseidonContract from "./src/poseidon_gencontract.js";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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