Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from js-sha3 to audited noble-hashes #416

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var fastFile = require('fastfile');
var circom_runtime = require('circom_runtime');
var r1csfile = require('r1csfile');
var ejs = require('ejs');
var jsSha3 = require('js-sha3');
var sha3 = require('@noble/hashes/sha3');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

Expand Down Expand Up @@ -39,7 +39,6 @@ var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
var fastFile__namespace = /*#__PURE__*/_interopNamespace(fastFile);
var ejs__default = /*#__PURE__*/_interopDefaultLegacy(ejs);
var jsSha3__default = /*#__PURE__*/_interopDefaultLegacy(jsSha3);

const bls12381r$1 = ffjavascript.Scalar.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
const bn128r$1 = ffjavascript.Scalar.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");
Expand Down Expand Up @@ -6975,7 +6974,6 @@ class Proof {
You should have received a copy of the GNU General Public License along with
snarkjs. If not, see <https://www.gnu.org/licenses/>.
*/
const { keccak256 } = jsSha3__default["default"];

const POLYNOMIAL = 0;
const SCALAR = 1;
Expand Down Expand Up @@ -7023,7 +7021,7 @@ class Keccak256Transcript {
}
}

const value = ffjavascript.Scalar.fromRprBE(new Uint8Array(keccak256.arrayBuffer(buffer)));
const value = ffjavascript.Scalar.fromRprBE(sha3.keccak_256(buffer));
return this.Fr.e(value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
},
"dependencies": {
"@iden3/binfileutils": "0.0.11",
"@noble/hashes": "^1.3.1",
"bfj": "^7.0.2",
"blake2b-wasm": "^2.4.0",
"circom_runtime": "0.1.24",
"ejs": "^3.1.6",
"fastfile": "0.0.20",
"ffjavascript": "0.2.60",
"js-sha3": "^0.8.0",
"logplease": "^1.2.15",
"r1csfile": "0.0.47"
},
Expand Down
5 changes: 2 additions & 3 deletions src/Keccak256Transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import {Scalar} from "ffjavascript";
import jsSha3 from "js-sha3";
const { keccak256 } = jsSha3;
import {keccak_256} from "@noble/hashes/sha3";

const POLYNOMIAL = 0;
const SCALAR = 1;
Expand Down Expand Up @@ -67,7 +66,7 @@ export class Keccak256Transcript {
}
}

const value = Scalar.fromRprBE(new Uint8Array(keccak256.arrayBuffer(buffer)));
const value = Scalar.fromRprBE(keccak_256(buffer));
return this.Fr.e(value);
}
}