Skip to content

Commit

Permalink
update the max_number placeholder for range proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello committed Jan 16, 2025
1 parent bc67f25 commit 8ef4267
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 7 deletions.
5 changes: 3 additions & 2 deletions integration-tests/verification-flow/proof-requests.ts

Large diffs are not rendered by default.

91 changes: 88 additions & 3 deletions integration-tests/verification-flow/range-proofs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
import {createVerificationController} from '@docknetwork/wallet-sdk-core/src/verification-controller';
import {createProofRequest} from '../helpers/certs-helpers';
import axios from 'axios';
import {boundCheckSnarkKey} from './proof-requests';

describe('Range proofs verification', () => {
it('should verify range proofs presentation without subject', async () => {
it('should create range proofs presentation without subject', async () => {
const wallet: IWallet = await getWallet();
const controller = await createVerificationController({
wallet,
Expand Down Expand Up @@ -46,9 +47,93 @@ describe('Range proofs verification', () => {
expect(
presentation.verifiableCredential[0].credentialSubject,
).toBeUndefined();
});

it('should generate range proofs presentation using number max placeholder', async () => {
const wallet: IWallet = await getWallet();
const controller = await createVerificationController({
wallet,
});

const credentialUrl =
'https://creds-testnet.truvera.io/3e824efbead0f72cbe0070923d981762122bf5440cfce513e96b65482ea4934a';
const password = '1234';
const {data: credential} = await axios.get(
`${credentialUrl}?p=${btoa(password)}`,
);

await getCredentialProvider().addCredential(credential);

const result = await controller.submitPresentation(presentation);
expect(result.verified).toBe(true);
await controller.start({
template: {
boundCheckSnarkKey,
signature: null,
qr: 'https://creds-testnet.truvera.io/proof/b8acdd33-e8e0-491f-8674-6ba521d9ea84',
id: 'b8acdd33-e8e0-491f-8674-6ba521d9ea84',
name: 'test data',
nonce: '798b999c18bb83f0f9669aac91c68910',
created: '2025-01-15T16:34:06.077Z',
response_url:
'https://api-testnet.truvera.io/proof-requests/b8acdd33-e8e0-491f-8674-6ba521d9ea84/send-presentation',
request: {
id: 'b8acdd33-e8e0-491f-8674-6ba521d9ea84',
input_descriptors: [
{
id: 'Credential 1',
name: 'test data',
purpose: 'test',
constraints: {
fields: [
{
path: ['$.credentialSubject.id'],
optional: false,
},
{
path: ['$.credentialSubject.number'],
filter: {
type: 'number',
exclusiveMinimum: 0,
},
optional: false,
predicate: 'required',
},
{
path: ['$.credentialSchema.id'],
filter: {
const:
'https://schema.truvera.io/TestingCheqdSchema-V1-1736958567072.json',
},
},
{
path: ['$.credentialSubject.name'],
optional: false,
},
],
},
},
],
},
type: 'proof-request',
},
});

const attributesToReveal = [
'credentialSubject.id',
'credentialSubject.name',
'credentialSubject.date',
'credentialSubject.number',
];

controller.selectedCredentials.set(credential.id, {
credential: credential,
attributesToReveal,
});

const presentation = await controller.createPresentation();

expect(
presentation.verifiableCredential[0].credentialSubject,
).toBeDefined();
});

afterAll(() => closeWallet());
Expand Down
4 changes: 2 additions & 2 deletions packages/wasm/src/services/credential/pex-helpers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {JSONPath} from '@astronautlabs/jsonpath';

export const EPSILON_NUMBER = 0.0001;
export const EPSILON_NUMBER = 0.001;
export const EPSILON_INT = 1;

export const MAX_DATE_PLACEHOLDER = 884541351600000;
export const MIN_DATE_PLACEHOLDER = -17592186044415;
export const MAX_NUMBER = 100 ** 6;
export const MAX_NUMBER = 100 ** 5;
export const MIN_NUMBER = -4294967294;

/*
Expand Down

0 comments on commit 8ef4267

Please sign in to comment.