Skip to content

Commit

Permalink
range proofs part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello committed Aug 31, 2023
1 parent 71b4094 commit 8a6ee5d
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: 'node',
testTimeout: 30000,
maxConcurrency: 2,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ verificationCommands
template = await clipboardy.read();
}
}

console.log('Got template', template);

console.log('Starting verification flow...');
await controller.start({
template,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ function isURL(str) {
}

export function getJSONFromURL(url: string) {
return axios.get(url).then(res => res.data);
return axios
.get(url)
.then(res => res.data)
.catch(err => {
console.error(`Error fetching ${url}`, err);
});
}

export function getJSON(jsonOrURL: string | any) {
Expand All @@ -24,6 +29,7 @@ export function getJSON(jsonOrURL: string | any) {

if (typeof jsonOrURL === 'string') {
if (isURL(jsonOrURL)) {
console.log(`Fetching ${jsonOrURL}`);
return getJSONFromURL(jsonOrURL);
} else {
return JSON.parse(jsonOrURL);
Expand Down
5 changes: 4 additions & 1 deletion packages/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"devDependencies": {
"realm": "^10.10.1",
"@babel/node": "^7.16.0",
"sinon": "^12.0.1"
"sinon": "^12.0.1",
"jest": "29.6.1",
"ts-jest": "29.1.0",
"typescript": "^5.0.4"
}
}
9 changes: 9 additions & 0 deletions packages/wasm/src/services/credential/range-proof.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {createRangeProofPresentation} from "./range-proof";
import {utilCryptoService} from "../util-crypto";

describe('Test range proofs', () => {
it('expect presentation to be created', async () => {
const result = await createRangeProofPresentation();
expect(result).toBe(true);
});
});
16 changes: 16 additions & 0 deletions packages/wasm/src/services/credential/range-proof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {LegoProvingKeyUncompressed, LegoVerifyingKeyUncompressed, LegoProvingKey } from '@docknetwork/crypto-wasm-ts/lib/legosnark'
import {BoundCheckSnarkSetup} from '@docknetwork/crypto-wasm-ts/lib/bound-check';
import {initializeWasm} from '@docknetwork/crypto-wasm-ts/lib/index';

export async function createRangeProofPresentation() {
await initializeWasm();

// let snarkProvingKey: LegoProvingKeyUncompressed;
// let snarkVerifyingKey: LegoVerifyingKeyUncompressed;
//
const pk:LegoProvingKey = BoundCheckSnarkSetup();
// snarkProvingKey = pk.decompress();
// snarkVerifyingKey = pk.getVerifyingKeyUncompressed();

return true;
}
4 changes: 4 additions & 0 deletions packages/wasm/src/services/credential/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class CredentialService {
return VerifiableCredential.fromJSON(credentialJSON);
});
}

async testRangeProof() {
console.log('test')
}
}

export const credentialService = new CredentialService();
4 changes: 1 addition & 3 deletions packages/wasm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@
},
"esm": true
},
"include": ["src/**/*"],
"exclude": ["**/__tests__/**/*", "**/build/**/*"]
"include": ["src/**/*"]
}

12 changes: 6 additions & 6 deletions setup-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const cfg = {url: 'http://localhost'};
const dom = new JSDOM('', cfg);
global.window = dom.window;
global.document = dom.window.document;

Object.keys(global.window).forEach(property => {
if (typeof global[property] === 'undefined') {
global[property] = global.window[property];
}
});
//
// Object.keys(global.window).forEach(property => {
// if (typeof global[property] === 'undefined') {
// global[property] = global.window[property];
// }
// });

global.navigator = {
userAgent: 'node.js',
Expand Down

0 comments on commit 8a6ee5d

Please sign in to comment.