Skip to content

Commit

Permalink
Add suggestions from @just-mitch on #4429
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Feb 6, 2024
1 parent b23bac5 commit 079368a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/contract/contract_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
export function getContractClassFromArtifact(
artifact: ContractArtifact | ContractArtifactWithHash,
): ContractClassWithId {
const artifactHash = (artifact as ContractArtifactWithHash).artifactHash ?? computeArtifactHash(artifact);
const artifactHash = 'artifactHash' in artifact ? artifact.artifactHash : computeArtifactHash(artifact);
const publicFunctions: ContractClass['publicFunctions'] = artifact.functions
.filter(f => f.functionType === FunctionType.OPEN)
.map(f => ({
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/end-to-end/src/e2e_deploy_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ describe('e2e_deploy_contract', () => {
// since it's common to provide all hash preimages to a function that verifies them.
const artifactMetadataHash = computeArtifactMetadataHash(artifact);
const unconstrainedArtifactFunctionTreeRoot = computeArtifactFunctionTreeRoot(artifact, FunctionType.OPEN);

// We need two sibling paths because private function information is split across two trees:
// The "private function tree" captures the selectors and verification keys, and is used in the kernel circuit for verifying the proof generated by the app circuit.
// The "artifact tree" captures function bytecode and metadata, and is used by the pxe to check that its executing the code it's supposed to be executing, but it never goes into circuits.
const privateFunctionTreePath = computePrivateFunctionsTree(contractClass.privateFunctions).getSiblingPath(0);
const artifactFunctionTreePath = computeArtifactFunctionTree(artifact, FunctionType.SECRET)!.getSiblingPath(0);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/abi/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function bufferAsFields(input: Buffer, targetLength: number): Fr[] {
const encoded = [
new Fr(input.length),
...chunk(input, Fr.SIZE_IN_BYTES - 1).map(c => {
const fieldBytes = Buffer.alloc(32);
const fieldBytes = Buffer.alloc(Fr.SIZE_IN_BYTES);
Buffer.from(c).copy(fieldBytes, 1);
return Fr.fromBuffer(fieldBytes);
}),
Expand Down

0 comments on commit 079368a

Please sign in to comment.