Skip to content

Commit

Permalink
modify: Service - dto 수정
Browse files Browse the repository at this point in the history
verify API 인자에 맞게 동기화시킴
  • Loading branch information
Lee-clipse committed May 1, 2024
1 parent 82929c4 commit 9001f20
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
35 changes: 12 additions & 23 deletions BE/service/src/dto/proof.dto.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import { ApiProperty } from '@nestjs/swagger';

export class ProofDto {
@ApiProperty({
description: 'Service Name',
example: 'One-sided love paper boat',
})
readonly ServiceName: string;

@ApiProperty({ description: 'Holder pub key', example: 'hpubkey' })
readonly HolderPubKey: string;

@ApiProperty({ description: 'Proof', example: 'proof' })
@ApiProperty({ description: 'Proof (by json)', example: 'proof' })
readonly proof: string;

@ApiProperty({ description: 'Issuer pub key', example: 'ipubkey' })
@ApiProperty({ description: 'Issuer pub key (by json)', example: 'ipubkey' })
readonly IssuerPubKey: string;

// TODO: might be deprecated
@ApiProperty({ description: 'Major code', example: '12' })
readonly majorCode: string;

@ApiProperty({ description: 'Message', example: 'message' })
readonly message: string;

@ApiProperty({
description: 'Params',
type: 'object',
example: { data: 'something' },
})
params: object;

@ApiProperty({ description: 'VKey(Uint8Array -> String)', example: 'vkey' })
vkey: string;
// @ApiProperty({ description: 'user pk', example: 'pk' })
// readonly pk: string;

@ApiProperty({
description: 'Strategy(Uint8Array -> String)',
example: 'strategy',
})
strategy: string;
@ApiProperty({ description: 'VKey (by json)', example: 'vkey' })
readonly vKey: string;
}
5 changes: 4 additions & 1 deletion BE/verifier/src/dto/proof.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ApiProperty } from '@nestjs/swagger';

export class ProofDto {
@ApiProperty({ description: 'Service Name', example: 'One-sided love paper boat' })
@ApiProperty({
description: 'Service Name',
example: 'One-sided love paper boat',
})
readonly ServiceName: string;

@ApiProperty({ description: 'Holder pub key', example: 'hpubkey' })
Expand Down
11 changes: 7 additions & 4 deletions BE/verifier/src/verifier/verifier-api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { CustomErrorException } from '../filter/custom-error.exception';
@Controller('api/verifier')
@ApiTags('VERIFIER API')
export class VerifierAPIController {
constructor(private readonly verifierAPIService: VerifierAPIService) { }
constructor(private readonly verifierAPIService: VerifierAPIService) {}

@Post('verify-proof')
@ApiOperation({
summary: '생성된 Proof를 검증',
})

async verifyProof(@Body() dto: ProofDto): Promise<boolean> {
const { ServiceName, HolderPubKey, proof, IssuerPubKey, vKey } = dto;

Expand All @@ -27,11 +26,15 @@ export class VerifierAPIController {

// Send data to blockchain (NEAR)
try {
if (await this.verifierAPIService.loadProofResult(ServiceName, HolderPubKey)) {
const verifyResult = await this.verifierAPIService.loadProofResult(
ServiceName,
HolderPubKey,
);
if (verifyResult) {
return true;
} else {
throw new CustomErrorException('Verify Load Failed', 502);
};
}
} catch (error) {
throw new CustomErrorException('Verfiy Load Failed', 502);
}
Expand Down
1 change: 0 additions & 1 deletion BE/verifier/src/verifier/verifier-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class VerifierAPIService {
IssuerPubKeyJson,
vKeyJson,
);

// verify success
const res = await groth16.verify(vKey, IssuerPubKey, proof);

Expand Down

0 comments on commit 9001f20

Please sign in to comment.