Skip to content

Commit

Permalink
Add extra 0 to end of Bool.toBits so that Scalar.fromBits is happy
Browse files Browse the repository at this point in the history
  • Loading branch information
jackryanservia committed Mar 4, 2024
1 parent e63f421 commit c14178a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit c14178a

Please sign in to comment.