From c14178afa92fb702734f41a88c0e9abc533084ef Mon Sep 17 00:00:00 2001 From: jackryanservia <90076280+jackryanservia@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:09:14 +0000 Subject: [PATCH] Add extra 0 to end of Bool.toBits so that Scalar.fromBits is happy --- src/lib/nullifier.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/nullifier.ts b/src/lib/nullifier.ts index c8e84984ef..033187685d 100644 --- a/src/lib/nullifier.ts +++ b/src/lib/nullifier.ts @@ -5,6 +5,7 @@ import { Poseidon } from './hash.js'; import { MerkleMapWitness } from './merkle-map.js'; import { PrivateKey, PublicKey, scaleShifted } from './signature.js'; import { Provable } from './provable.js'; +import { Bool } from './bool.js'; export { Nullifier }; @@ -70,7 +71,10 @@ class Nullifier extends Struct({ // shifted scalar see https://github.com/o1-labs/o1js/blob/5333817a62890c43ac1b9cb345748984df271b62/src/lib/signature.ts#L220 // pk^c - let pk_c = scaleShifted(this.publicKey, Scalar.fromBits(c.toBits())); + let pk_c = scaleShifted( + this.publicKey, + Scalar.fromBits(c.toBits().concat(new Bool(false))) + ); // g^r = g^s / pk^c let g_r = G.scale(s).sub(pk_c); @@ -80,7 +84,10 @@ class Nullifier extends Struct({ // h_m_pk_r = h(m,pk)^s / nullifier^c let h_m_pk_s_div_nullifier_s = h_m_pk_s.sub( - scaleShifted(nullifier, Scalar.fromBits(c.toBits())) + scaleShifted( + nullifier, + Scalar.fromBits(c.toBits().concat(new Bool(false))) + ) ); // this is supposed to match the entries generated on "the other side" of the nullifier (mina-signer, in an wallet enclave)