-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19cfead
commit 504683c
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Abi, InputMap, abiEncode } from '@noir-lang/noirc_abi'; | ||
import { readTomlObject } from '../../util/file.js'; | ||
import { Hex } from 'viem'; | ||
import { CircuitAbi } from './abi.js'; | ||
|
||
export class VerifierData { | ||
public static async create(verifierTomlPath: string, abi: Abi) { | ||
const verifierData = await readTomlObject<InputMap>(verifierTomlPath); | ||
return new VerifierData(new CircuitAbi(abi), verifierData); | ||
} | ||
|
||
public publicInputs(): Hex[] { | ||
return this.encodeSubset(this.abi.public()); | ||
} | ||
|
||
public returnValues(): Hex[] { | ||
return this.encodeSubset(this.abi.return()); | ||
} | ||
|
||
public encodeSubset(subset: Abi): Hex[] { | ||
const subsetEncodedMap = abiEncode(subset, this.verifierData, this.verifierData.return); | ||
return Array.from(subsetEncodedMap.values()) as Hex[]; | ||
} | ||
|
||
private constructor( | ||
private abi: CircuitAbi, | ||
private verifierData: InputMap | ||
) {} | ||
} |