Skip to content

Commit

Permalink
fix: use correct offset when converting commitment to bigint (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
adklempner authored Mar 22, 2024
1 parent 3dc5908 commit 126bce3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class IdentityCredential {
const idNullifier = memKeys.subarray(32, 64);
const idSecretHash = memKeys.subarray(64, 96);
const idCommitment = memKeys.subarray(96);
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment, 96);

return new IdentityCredential(
idTrapdoor,
Expand Down
7 changes: 5 additions & 2 deletions src/utils/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ export function writeUIntLE(
* @param array: Uint8Array
* @returns BigInt
*/
export function buildBigIntFromUint8Array(array: Uint8Array): bigint {
export function buildBigIntFromUint8Array(
array: Uint8Array,
byteOffset: number = 0
): bigint {
const dataView = new DataView(array.buffer);
return dataView.getBigUint64(0, true);
return dataView.getBigUint64(byteOffset, true);
}

/**
Expand Down

0 comments on commit 126bce3

Please sign in to comment.