Merge branch 'main' into test/ecc_circuits

This commit is contained in:
Daniel Tehrani
2023-02-02 15:33:18 +09:00
2 changed files with 4 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
import { hashPersonalMessage, ecsign } from "@ethereumjs/util";
import { EffEcdsaCircuitPubInput } from "@personaelabs/spartan-ecdsa";
import { computeEffEcdsaPubInput } from "@personaelabs/spartan-ecdsa";
export const getEffEcdsaCircuitInput = (privKey: Buffer, msg: Buffer) => {
const msgHash = hashPersonalMessage(msg);
const { v, r: _r, s } = ecsign(msgHash, privKey);
const r = BigInt("0x" + _r.toString("hex"));
const circuitPubInput = EffEcdsaCircuitPubInput.computeFromSig(r, v, msgHash);
const circuitPubInput = computeEffEcdsaPubInput(r, v, msgHash);
const input = {
s: BigInt("0x" + s.toString("hex")),
Tx: circuitPubInput.Tx,

View File

@@ -2,10 +2,10 @@ import {
CircuitPubInput,
PublicInput,
verifyEffEcdsaPubInput
} from "../src/helpers/efficient_ecdsa";
} from "../src/helpers/public_input";
import { hashPersonalMessage } from "@ethereumjs/util";
describe("efficient_ecdsa", () => {
describe("public_input", () => {
/**
Hard coded values were computed in sage using the following code
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f