Skip to content

Commit

Permalink
feat: add extractMetadata function
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Apr 28, 2023
1 parent 777e363 commit 15c0794
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/rln.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ const shareYOffset = shareXOffset + 32;
const nullifierOffset = shareYOffset + 32;
const rlnIdentifierOffset = nullifierOffset + 32;

export class ProofMetadata {
constructor(
public readonly nullifier: Uint8Array,
public readonly shareX: Uint8Array,
public readonly shareY: Uint8Array,
public readonly externalNullifier: Uint8Array
) {}
}
export class Proof implements IRateLimitProof {
readonly proof: Uint8Array;
readonly merkleRoot: Uint8Array;
Expand All @@ -123,6 +131,16 @@ export class Proof implements IRateLimitProof {
rlnIdentifierOffset
);
}

extractMetadata(): ProofMetadata {
const externalNullifier = poseidonHash(this.epoch, this.rlnIdentifier);
return new ProofMetadata(
this.nullifier,
this.shareX,
this.shareY,
externalNullifier
);
}
}

export function proofToBytes(p: IRateLimitProof): Uint8Array {
Expand Down

0 comments on commit 15c0794

Please sign in to comment.